<?php
Generate Captcha Picture
Header ("Content-type:image/png");
Srand ((double) Microtime () *1000000);//sow a seed that generates random numbers to facilitate the use of the following random number generation
Session_Start ()//to store random numbers in session
$_session[' authnum ']= ' ";
$im = Imagecreate (62,20); Make picture background size
$black = Imagecolorallocate ($im, 0,0,0); Set Three Colors
$white = Imagecolorallocate ($im, 255,255,255);
$gray = Imagecolorallocate ($im, 200,200,200);
Imagefill ($im, 0,0, $gray); Using area filling method, setting (0,0)
while (($authnum =rand () 0000) <10000);
To draw a four-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 images (the upper-left corner of the image is 0, 0).
If font is 1,2,3,4 or 5, the built-in font is used
for ($i =0; $i <200; $i)//Add interference pixels
{
$randcolor = Imagecolorallocate ($im, Rand (0,255), Rand (0,255), Rand (0,255));
Imagesetpixel ($im, Rand () p, rand () 0, $randcolor);
}
Imagepng ($im);
Imagedestroy ($im);
?>