English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have made 3 files like this:

New Text Document.php











script.php
session_start();
$alphanum= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
$rand = substr(str_shuffle($alphanum), 0, 5);
$_SESSION['image_random_value'] = md5($rand);
$image = imagecreate(35, 20);
$bgColor = imagecolorallocate ($image, 255, 255, 255);
$textColor = imagecolorallocate ($image, 0, 0, 0);
imagestring ($image, 3, 1, 2, $rand, $textColor);
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
?>

2006-07-24 07:05:42 · 2 answers · asked by QuestionAnswer 2 in Computers & Internet Programming & Design

o.php
if (!($_SESSION['image_random_value'] == md5($_POST['captcha_field']))) {
die("Wrong CAPTCHA value!");
} else {
echo "CAPTCHA Image Verified!";
}
?>


when I run the Text Document.php I'm getting this error:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\New Text Document.php:5) in C:\wamp\www\script.php on line 2

Fatal error: Call to undefined function imagecreate() in C:\wamp\www\script.php on line 16

2006-07-24 07:07:08 · update #1

how to handle error?

2006-07-24 07:10:14 · update #2

2 answers

for the image create, you have to make sure the image generating libraries were compiled in to PHP, for that you also need GD.

If you do a phpinfo(); on a page by itself you should see all of the libraries that are compiled into PHP (along with a lot of other info).

For the session_start issue, you have to make sure nothing else (including white space) is before the PHP block that contains it, and no echos or prints are before it (same goes for any other header() or setcookie() calls)

2006-07-24 07:21:57 · answer #1 · answered by John J 6 · 0 0

so what is your question

2006-07-24 07:07:42 · answer #2 · answered by rachelle105210 5 · 0 0

fedest.com, questions and answers