1. A. php
<? PHP
Session_start ();
Function random ($ Len)
{
$ Srcstr = "abcdefghijklmnopqrstuvwxyz0123456789 ";
Mt_srand ();
$ STRs = "";
For ($ I = 0; $ I <$ Len; $ I ++ ){
$ STRs. = $ srcstr [mt_rand (0, 35)];
}
Return strtoupper ($ STRs );
}
$ STR = random (4); // randomly generated string
$ Width = 50; // The image width of the Verification Code
$ Height = 25; // height of the Verification Code Image
@ Header ("Content-Type: image/PNG ");
$ _ Session ["code"] = $ STR;
// Echo $ STR;
$ Im = imagecreate ($ width, $ height );
// Background color
$ Back = imagecolorallocate ($ im, 0xff, 0xff, 0xff );
// Blur the vertex color
$ Pix = imagecolorallocate ($ im, 187,230,247 );
// Font color
$ Font = imagecolorallocate ($ im, 41,163,238 );
// Plot the vertices of fuzzy match.
Mt_srand ();
For ($ I = 0; I I <1000; $ I ++)
{
Imagesetpixel ($ im, mt_rand (0, $ width), mt_rand (0, $ height), $ pix );
}
Imagestring ($ im, 5, 7, 5, $ STR, $ font );
Imagerectangle ($ im, 0, 0, $ width-1, $ height-1, $ font );
Imagepng ($ IM );
Imagedestroy ($ IM );
$ _ Session ["code"] = $ STR;
?>
2. B. php
<? PHP
// Include_once ('identifying. php ');
Session_start (); // code for generating the verification code
Echo " Echo $ _ session ["code"]; // generate the verification code value ?>
Add graphic Verification Code