问题:怎样能将图片中的验证码储存起来用于后期的验证?
verficode.php 页面
ob_clean();
for($i=0;$i $num.=dechex(rand(0,15));
}
$num=substr($num,-4,4);
$nowimage=imagecreate(100,30);
imagecolorallocate($nowimage,240,240,240);
for($i=0;$i
$x=mt_rand(1,8)+100*$i/4;
$y=mt_rand(1,50/4);
$color=imagecolorallocate($nowimage,rand(0,150),rand(0,150),rand(0,150));
imagestring($nowimage,$font,$x,$y,$num[$i],$color);
}
for($i=0;$i $randcolor=imagecolorallocate($nowimage,rand(200,255),rand(200,255),rand(200,255));
imagesetpixel($nowimage,rand()%70,rand()%20,$randcolor);
}
header("content-type:image/png");
imagepng($nowimage);
imagedestroy($nowimage);
?>
index.php 页面
保存到SESSION
session 可以
一般验证码都是保存到session里面然后采用输入框里面的数据与session里面对应验证码的字段进行匹配后进行判断的。不知道lz是想要什么样的。
把你的验证码方法,封装为类方法,需要的时候直接实例化类就可以用,记得session_start();
#5
但是在index.php 页面接受的$_SESSION['captcha']的数据和验证码显示出来的数据不同步(慢了一步)
index.php 的接受验证码比verficode.php 页面接收的验证码慢了一步
什?叫慢一步?
index.php 先于 verficode.php 执行,慢一步是正常的
所以 zf 采用了保存验证码图片的方案
前几天才在这里讨论过,你可找一下
知道了,谢啦
已抢65036个
抢已抢27970个
抢已抢15116个
抢已抢7608个
抢已抢9494个
抢已抢19252个
抢