<?php
//session_start();
for($k=0;$k<8;$k++){
$rand.=dechex(rand(1,15));
}
header("Content-type:image/png");
$img=imagecreatetruecolor(100,20);
$bgcolor=imagecolorallocate($img,0,0,0);
$ziti=imagecolorallocate($img,255,255,255);
imagestring($img,6,rand(1,30),rand(1,5),$rand,$ziti);
imagejpeg($img);
$_SESSION[check_img]=$rand;
?>
------------PHP验证码生成页面怎么不能加include引用页~~~ 一加图片就是个小X了! 但是我必须要加啊!!!
<?php
include_once "xx.php";//这样就错了.
for($k=0;$k<8;$k++){
$rand.=dechex(rand(1,15));
}
header("Content-type:image/png");
$img=imagecreatetruecolor(100,20);
$bgcolor=imagecolorallocate($img,0,0,0);
$ziti=imagecolorallocate($img,255,255,255);
imagestring($img,6,rand(1,30),rand(1,5),$rand,$ziti);//第2个参数也可以,rand(1,6)
imagejpeg($img);
$_SESSION[check_img]=$rand;
?>
//session_start();
for($k=0;$k<8;$k++){
$rand.=dechex(rand(1,15));
}
header("Content-type:image/png");
$img=imagecreatetruecolor(100,20);
$bgcolor=imagecolorallocate($img,0,0,0);
$ziti=imagecolorallocate($img,255,255,255);
imagestring($img,6,rand(1,30),rand(1,5),$rand,$ziti);
imagejpeg($img);
$_SESSION[check_img]=$rand;
?>
------------PHP验证码生成页面怎么不能加include引用页~~~ 一加图片就是个小X了! 但是我必须要加啊!!!
<?php
include_once "xx.php";//这样就错了.
for($k=0;$k<8;$k++){
$rand.=dechex(rand(1,15));
}
header("Content-type:image/png");
$img=imagecreatetruecolor(100,20);
$bgcolor=imagecolorallocate($img,0,0,0);
$ziti=imagecolorallocate($img,255,255,255);
imagestring($img,6,rand(1,30),rand(1,5),$rand,$ziti);//第2个参数也可以,rand(1,6)
imagejpeg($img);
$_SESSION[check_img]=$rand;
?>
图片的文件名自己想好没规律的而且还随机产生 当然这个你就要处理好文件名的对应关系了。
这样那些灌水机也很难有机可趁的,是不是...输入正确了将答案加密一下传递到验证页面,验证页面再根据随机公式进行检验解密后结果是否一致.
方法很多呀 千万别纠结...
header("Content-type:image/png");
不能执行...
解决 清除XX.PHP里面的输出的字符...UTF-8的话 再清除BOM 就可以了...
反正就不能有任何 ECHO 输出!