About PHP Generation Verification code
The code is as follows
Header ("Content-type:image/png");
Srand (Double) microtime () *1000000);//sow a seed that generates random numbers to facilitate the use of random number generation below
Session_Start ();//storing random numbers in session
$_session[' Authnum ']= "";
$im = Imagecreate (70,20) or Die ("Cant ' Initialize new GD image stream!"); Make picture background size
$black = Imagecolorallocate ($im, 0,0,0); Set of three Colors
$white = Imagecolorallocate ($im, 255,255,255);
$gray = Imagecolorallocate ($im, 200,200,200);
Imagefill ($im, 0,0, $gray); Using area Fill method, set (0,0)
Code method for generating mixed numbers and letters
$ychar = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
$list =explode (",", $ychar);
for ($i =0; $i <4; $i + +) {
$randnum =rand (0,35);
$authnum. = $list [$randnum];
}
while (($authnum =rand ()%100000) <10000); Generate a random number of five
Drawing a five-bit integer verification code into a picture
$_session[' Authnum ']= $authnum;
Imagestring ($im, 5, 3, $authnum, $black);
Use the col color to draw the string s to the x, y coordinates of the image represented by the image (0, 0 in the upper-left corner).
If the font is 1,2,3,4 or 5, use the built-in font
for ($i =0; $i <200; $i + +)//Add interfering pixels
{
$randcolor = Imagecolorallocate ($im, Rand (0,255), Rand (0,255), Rand (0,255));
Imagesetpixel ($im, Rand ()%70, Rand ()%30, $randcolor);
}
Imagepng ($im);
Imagedestroy ($im);
?>
And the GD library is open, but the picture is not generated. Please advise us
------Solution--------------------
Quote:
It's already open.
The code is OK, you first put $_session[' code ' = $verifyCode; Comment out it's not going to open the SESSION. It's probably your environment, and my test is fine.