求个PHP验证码

求个PHP验证码

求个PHP验证码

最好是放在SESSION里的 。。。

谢谢大家

引用:
[quote]

[复制到剪切板]
CODE:
<?
//生成新的四位整数验证码
session_start();//开始会话
$authnum ''
$str 'abcdefghijkmnpqrstuvwxyz1234567890'
$l strlen($str); 
for(
$i=1;$i<=4;$i++)

$num=rand(0,$l); 
$authnum.= $str[$num]; 
}
//生成SESSION变量
$_SESSION['code']=$authnum;
//生成验证码图片
Header("Content-type: image/PNG");
srand((double)microtime()*1000000);
$im imagecreate(50,20);
$black ImageColorAllocate($im0,0,0);
$white ImageColorAllocate($im255,255,255);
$gray ImageColorAllocate($im200,200,200);
imagefill($im,68,30,$gray);
//将四位整数验证码绘入图片
imagestring($im563$authnum$white);
for(
$i=0;$i<90;$i++) //加入干扰象素
{
imagesetpixel($imrand()%70 rand()%30 $gray);
}
ImagePNG($im);
ImageDestroy($im);
?> ;




[复制到剪切板]
CODE:
<?
if(
$checkcode!=$_SESSION['code'])
{
      echo 
"<script language=\"javascript\">alert(\"验证码错误!\")<\/script>";
}
?>
不知道可是你需要的. ;

[/quote]

[ 本帖最后由 fangkejie 于 2008-5-8 16:46 编辑 ]

8错!简单又实用!
我的Blog

偷用了,嘻