Simple Captcha Code

Posted: September 22, 2012 in All Category

Hey you can use very simple captcha code ………

here  cap_bg.jpg you can use background image as like this…….

this is captcha.php file 

<?php
session_start();
$ranStr = md5(microtime());
$ranStr = substr($ranStr, 0, 6);
$_SESSION[‘cap_code’] = $ranStr;
$newImage = imagecreatefromjpeg(“cap_bg.jpg”);
$txtColor = imagecolorallocate($newImage, 0, 0, 0);
imagestring($newImage, 5, 5, 5, $ranStr, $txtColor);
header(“Content-type: image/jpeg”);
imagejpeg($newImage);
?>

And show captcha code here as like this…..

index.php  file 

session_start();

<td width=”60px”>
<input type=”text” name=”captcha” id=”captcha” maxlength=”6″ size=”6″/></td>
<td><img src=”captcha.php”/></td>

if ($_POST[‘captcha’] == $_SESSION[‘cap_code’]) {

}

Advertisements

Comments are closed.