Friday, April 10, 2015

how to code for captcha in php

Hallo friends ...i am going to tell you how to write a code for captcha in php..


A CAPTCHA (an acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart")A captcha differentiate between human and computer. so here is the simple following code for captcha.you may change hex value to change the color.


<?php

$str=md5(microtime());

$str=substr($str,0,6);

session_start();

$_SESSION['captcha']=$str;

$img=imagecreate(50,50);

imagecolorallocate($img,199,199,199);

$txtcolor=imagecolorallocate($img,111,0,0);

imagestring($img,10,5,5,$str,$txtcolor);

header('content:image/jpeg');

imagejpeg($img);

?>

No comments:

Post a Comment