1 0){ 5 $temp=rand(1,3); 6 switch($temp){ 7 case 1: 8 $chars[]=sprintf("%c",rand(65,90)); 9 break;10 case 2:11 $chars[]=sprintf("%c",rand(97,122));12 break;13 case 3:14 $chars[]=sprintf("%c",rand(48,57));15 break;16 }17 }18 $str='';19 foreach($chars as $v){20 $str.=$v;21 }22 setcookie('checkcode',$str);23 $img = imagecreatetruecolor(count($chars)*9+18+($length_x-1)*10, 40);//924 $gray = imagecolorallocate($img, 0xC0,0xC0,0xC0);25 $dark_gray = imagecolorallocate($img, 0xAA,0xAA,0xAA);26 $bgcolor = imagecolorallocate($img, rand(0,255),rand(0,255),rand(0,255));27 imagefill($img, 0, 0, $bgcolor);28 $x=9;29 for($i=0;$i
1 2 314 验证码正确!{ $_GET[checkcode]}";18 else19 echo " 验证码错误!";20 }21 //6-21.php22 ?>23 241 4 7 8 9