<?PHPSession_Start();$checkcode="";/*For ($i =0; $i <4; $i + +) {$checkcode. =dechex (rand (1,15)); $checkcode. =rand (0,9);}*/functionGETSTR ($len= 4){ $str= ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ';$s= ' '; for($i= 0;$i<$len;$i++){$s.=$str{Mt_rand(0,strlen($str)-1)};}return $s;}$checkcode=getstr ();//Generate a random 4-bit verification code$_session[' Checkcode ']=$checkcode; Deposit Session$image 1=imagecreatetruecolor (110,30);//Create a canvas$red=imagecolorallocate ($image 1, 255,255,255);//Define Color for($i= 0;$i<10;$i++)//Interference Line{imageline ($image 1,Rand(0,110),Rand(0,30),Rand(0,110),Rand(0,30), Imagecolorallocate ($image 1,Rand(0,255),Rand(0,255),Rand(0,255)));} Imagestring ($image 1,Rand(3,8),Rand(0,80),Rand(0,15),$checkcode,$red); Create a pictureHeader("Content-type:image/png");
Imagepng ($image 1); Output Image Imagedestroy ($image 1); Destroying pictures?>
PHP captcha Code