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