在PHP中写了个验证码,在Firefox中总是出现“因其本身有错无法显示”
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>www.yuanshi88.com</title> 
</head> 
<body> 
<?php 
Header("Content-type: image/png"); 
session_start(); 
srand((double)microtime()*1000000); 
$im=imagecreate(45,18); 
$black=imagecolorallocate($im,0,0,0); 
$white=imagecolorallocate($im,255,255,255); 
$gray=imagecolorallocate($im,200,200,200); 
imagefill($im,0,0,$gray); 
session_register("autonum"); 
$_SESSION["autonum"]=""; 
for($i=0;$i<4;$i++){ 
$str=mt_rand(1,3); 
$size=mt_rand(3,6); 
$authnum=mt_rand(0,9); 
$_SESSION["autonum"]=$authnum; 
imagestring($im,$size,(5+$i*10),$str,$authnum,imagecolorallocate($im,rand(0,130),rand(0,130),rand(0,130))); 

for($i=0;$i<200;$i++){ 
$randcolor=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255)); 
imagesetpixel($im,rand()%70,rand()%30,$randcolor); 

imagepng($im); 
imagedestroy($im); 
?>  
</body> 
</html> 麻烦遇到过这个问题的各位大侠帮我解决下 
--------------------------------------------------------------------------------

解决方案 »

  1.   

    只要这部分就好了<?php 
    Header("Content-type: image/png"); 
    session_start(); 
    srand((double)microtime()*1000000); 
    $im=imagecreate(45,18); 
    $black=imagecolorallocate($im,0,0,0); 
    $white=imagecolorallocate($im,255,255,255); 
    $gray=imagecolorallocate($im,200,200,200); 
    imagefill($im,0,0,$gray); 
    session_register("autonum"); 
    $_SESSION["autonum"]=""; 
    for($i=0;$i<4;$i++){ 
    $str=mt_rand(1,3); 
    $size=mt_rand(3,6); 
    $authnum=mt_rand(0,9); 
    $_SESSION["autonum"]=$authnum; 
    imagestring($im,$size,(5+$i*10),$str,$authnum,imagecolorallocate($im,rand(0,130),rand(0,130),rand(0,130))); 

    for($i=0;$i<200;$i++){ 
    $randcolor=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255)); 
    imagesetpixel($im,rand()%70,rand()%30,$randcolor); 

    imagepng($im); 
    imagedestroy($im); 
    ?>