So can anyone help me please i want to add capcha in this script but i can't make it work please help me
It's very easy... make a form and add the image randomimage.php
and add the randomimage.php on the same folder:
// make a string with all the characters that we
// want to use as the verification code
$alphanum = "abcdefghijklmnopqrstuvwxyz123456789";
// generate the verication code
$rand = substr(str_shuffle($alphanum), 0, 5);
// create an image object using the chosen background
$image = imagecreatefromjpeg("background.jpg");
$textColor = imagecolorallocate ($image, 0, 0, 0);
// write the code on the background image
imagestring ($image, 5, 5, 5, $rand, $textColor);
// create the hash for the verification code
// and put it in the session
$rand = md5($rand);
$_SESSION['random'] = $rand ;
// send several headers to make sure the image is not cached
// taken directly from the PHP Manual
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
// send the content type header so the image is displayed properly
header('Content-type: image/jpeg');
// send the image to the browser
imagejpeg($image);
// destroy the image to free up the memory
imagedestroy($image);
?>
After, you need to verify if the user enter the right word on the field. the real text is in a Session variable :$_SESSION['random'] . Make sure you add md5 in yout verification or remove it in the randomimage.php . Also..add a backgound.jpg to add a backgroud imagne of your new capcha pics