Session_start ();
?>
<? PHP
// Generate a verification code Image
Header ("Content-Type: image/PNG ");
Srand (double) microtime () * 1000000); // play the next seed that generates random numbers to facilitate the use of the following Random Number Generation
// Session_start (); // Save the random number to the session.
$ _ Session ['authnum'] = "";
$ Im = imagecreate (70, 20) or die ("cant's initialize new GD image stream! "); // Specifies the image background size.
$ Black = imagecolorallocate ($ im, 0, 0); // you can specify three colors.
$ White = imagecolorallocate ($ im, 255,255,255 );
$ Gray = imagecolorallocate ($ im, 200,200,200 );
Imagefill ($ im, $ gray); // use the area filling method, set)
// Generate a verification code mixed with numbers and letters
$ Ychar = ", 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 students
// Print the five-digit integer verification code into the image
$ _ Session ['authnum'] = $ authnum;
Imagestring ($ im, 5, 10, 3, $ authnum, $ black );
// Use the col color to draw the string s to the X and Y coordinates of the image (0 and 0 in the upper left corner of the image ).
// If the font is 1, 2, 3, 4, or 5, use the built-in font.
For ($ I = 0; $ I <200; $ I ++) // Add interference pixels
{
$ Randcolor = imagecolorallocate ($ im, Rand (0,255), Rand (0,255), Rand (0,255 ));
Imagesetpixel ($ im, Rand () % 70, Rand () % 30, $ randcolor );
}
Imagepng ($ IM );
Imagedestroy ($ IM );
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.