<!----- FORM PAGE ------->
<?php
if(isset($_POST['captcha'])) { $captcha_string = $_SESSION['captcha'];
$user_input = md5($_POST['captcha']); if($user_input === $captcha_string) {
} else {
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Captcha</title>
<style type="text/css">
<!--
img {
border: 1px solid #000;
vertical-align: top;
}
#captcha {
height: 18px;
width: 48px;
border: 1px solid #000;
padding: 6px;
text-align: center;
font-weight: bold;
text-transform: uppercase;
font-size: 13px;
}
-->
</style>
</head>
<body>
<form action="<?php echo
$_SERVER['PHP_SELF']; ?>" method="post">
<img src="image.php"
alt="Error" />
<input type="text"
name="captcha" id="captcha" maxlength="5"
/>
<input type="submit"
value="Submit" name="submit" />
</form>
</body>
</html>
<!------- CAPTCHA IMAGE ------->
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header('Content-type: image/png');
$random_string = mt_rand(10000,
99999);
$_SESSION['captcha'] = md5($random_string);
$image = imagecreate(60, 30);
$image_background = imagecolorallocate($image, 255, 255, 255);
$image_text = imagecolorallocate($image, 0, 0, 0);
imagestring($image, 5, 8,
7, $random_string, $image_text);
imagepng($image);
imagedestroy($image);