Use PHP to implement the login verification code :? Phpsession_start (); session_register ("login_check_number"); // the result of the verification code on the chianren last night is considered, using the GD library of PHP to complete similar functions // first generate the background, and then
Use PHP to implement the login verification code:
Session_start ();
Session_register ('login _ check_number ');
// I saw the result of the verification code on chianren last night. I considered it and used the PHP GD library to complete similar functions.
// First generate the background, and then put the natural verification code
$ Img_height = 120; // define the length and width of the image first.
$ Img_width = 40;
If ($ HTTP_GET_VARS ['act '] = 'init '){
// Srand (microtime () * 100000); // srand is not required after PHP420
For ($ Tmpa = 0; $ Tmpa <4; $ Tmpa ){
$ Nmsg. = dechex (rand (0, 15 ));
} // By sports98
$ HTTP_SESSION_VARS [login_check_number] = $ nmsg;
// $ HTTP_SESSION_VARS [login_check_number] = strval
// Who can supplement it? can it contain both natural letters and numbers ?? ---- Completed by sports98
$ Aimg = imageCreate ($ img_height, $ img_width); // native image
ImageColorAllocate ($ aimg, 255,255,255); // image background color, ImageColorAllocate 1st definition color PHP considers it as background color
$ Black = ImageColorAllocate ($ aimg, 0); // you can specify the required color.
ImageRectangle ($ aimg, $ img_height-1, $ img_width-1, $ black); // wrap the picture into a Xuan-colored rectangle first
// The following is a natural snowflake background. it is actually a natural symbol on the image.
For ($ I = 1; $ I <= 200; $ I) {// test with 100
ImageString ($ aimg, 1, mt_rand (1, $ img_height), mt_rand (1, $ img_width), '*', imageColorAllocate ($ aimg, mt_rand (200,255 ), mt_rand (200,255), mt_rand (200,255 )));
// Ha, see it. it's actually not a snowflake, it's just a natural. In order to make them look 'disorganized, 5 colors and 6 colors', we have to make their status, color, and even size all use random numbers when they are born, both rand () and mt_rand can be completed.
}
// This is a natural background. now we should put the natural random number. The difference between the above and the above is a few. the random number is 1 place, and their status, size, and color are all used as random numbers ~~
// For the sake of difference from the background, the color here shall not exceed 200, and the color above shall not be less than 200
For ($ I = 0; $ I ImageString ($ aimg, mt_rand (), $ I * $ img_height/4 mt_rand (), mt_rand (1, $ img_width/2 ), $ HTTP_SESSION_VARS [login_check_number] [$ I], imageColorAllocate ($ aimg, mt_rand (0,100), mt_rand (0,150), mt_rand (0,200 )));