โค้ด captcha นี้ได้มาจากใน net นะค่ะ พอลองรันดูแล้วภาพ มันไม่ขึ้นอ่ะค่ะ ไม่รู้เพราะอะไร
Code (PHP)
<?php
// create a 100*30 image
$im = imagecreate(88, 31); <p>
// random colored background and text
$bg = imagecolorallocate($im, rand(0,255) , rand(0,255), rand(0,255));
$textcolor = imagecolorallocate($im, 0, 0, rand(0,255));
// write the random 4 digits number at a random locaton (x= 0-20, y=0-20),
$random=rand(1000,9999);
imagestring($im, rand(1,8), rand(0,20), rand(0,20), $random , $textcolor);
// write the image to a temporary file , in this case it is 777 chmoded tmp folder in same directory
// could be a generic /tmp folder
$filenametemp="tmp/gif".time().".gif";
ImageGIF($im, $filenametemp);
$ImageData = file_get_contents($filenametemp);
$ImageDataEnc = base64_encode($ImageData);
unlink($filenametemp); // delete the file
?>
Code
Enter number shown on image <input name="checkcode" type="text" id="checkcode" size="5">
<br>
<img src="data:image/gif;base64,<?=$ImageDataEnc?>" >
<input name="codemd5" type="hidden" id="codemd5" value="<?=md5($random)?>">
Code (PHP)
<?php
if (md5(trim($_REQUEST[checkcode]))!=$_REQUEST[codemd5] ) {
die (" wrong image protection code ");
} else {
//proceed further here
}
?>