<?php
session_start();
if(isset($_SESSION['code'])){
unset($_SESSION['code']);
}
?>
<?php
header("Content-Type:image/png");
$img=@imagecreate(90,80)or die("you can't create image ");
$background_color=imagecolorallocate($img,255,255,255);
$text_color=imagecolorallocate($img,255,0,0);
$line_color=imagecolorallocate($img,34,56,78);
imagefilledrectangle($img,10,10,80,70,$line_color);
for($i=0;$i<4;$i++){
$number=rand(0,2);
switch ($number){
case 0:
$randnumber=rand(48,57);break;//this is a dig number;
case 1:
$randnumber=rand(65,90);break;//this is a lower string;
case 2:
$randnumber=rand(97,122);break;//this is a upper stirng;
}
$asciinumber=sprintf("%c",$randnumber);
$lastnumber=$lastnumber.$asciinumber;
}
imagestring($img,5,30,30,$lastnumber,$text_color);
imagepng($img);
imagedestroy($img);
?>
<?php
$_SESSION['code']=$lastnumber;
?>
----------------------------验证的PHP代码
只显示了一个叉烧
session_start();
if(isset($_SESSION['code'])){
unset($_SESSION['code']);
}
?>
<?php
header("Content-Type:image/png");
$img=@imagecreate(90,80)or die("you can't create image ");
$background_color=imagecolorallocate($img,255,255,255);
$text_color=imagecolorallocate($img,255,0,0);
$line_color=imagecolorallocate($img,34,56,78);
imagefilledrectangle($img,10,10,80,70,$line_color);
for($i=0;$i<4;$i++){
$number=rand(0,2);
switch ($number){
case 0:
$randnumber=rand(48,57);break;//this is a dig number;
case 1:
$randnumber=rand(65,90);break;//this is a lower string;
case 2:
$randnumber=rand(97,122);break;//this is a upper stirng;
}
$asciinumber=sprintf("%c",$randnumber);
$lastnumber=$lastnumber.$asciinumber;
}
imagestring($img,5,30,30,$lastnumber,$text_color);
imagepng($img);
imagedestroy($img);
?>
<?php
$_SESSION['code']=$lastnumber;
?>
----------------------------验证的PHP代码
只显示了一个叉烧
session_start();
for($i=0;$i<4;$i++){
$rand.=dechex(rand(1,15));}
$_SESSION[check_pic]=$rand;
$im=imagecreatetruecolor(100,30);$te=imagecolorallocate($im,255,255,255);imagestring($im,rand(4,10),rand(3,80),rand(3,15),$rand,$te);
header("content-type:image/jpeg");
imagejpeg($im);
?>
这段代码是能运行的有显示上面的不显示啊,就是一个红色的叉
测试时你先把
header("Content-Type:image/png");
注释掉
如果有错就可以看到的
}
$asciinumber=sprintf("%c",$randnumber);
$lastnumber=[color=#FFFF00]$lastnumber.$asciinumber;
}
imagestring($img,5,30,30,$lastnumber,$text_color);
imagepng($img);
imagedestroy($img);
?>
打到错误了,是LISTNUMBER这里字符前后连接出错了,怎么能解决??[/color]