PHP generates a graphic verification code (mix uppercase and lowercase letters and numbers)
- Header ("content-type: image/png ");
- $ Num = $ _ GET ['num'];
- $ Imagewidth = 60;
- $ Imageheight = 18;
- Srand (microtime () * 100000 );
-
- $ Numimage = imagecreate ($ imagewidth, $ imageheight );
- Imagecolorallocate ($ numimage, 183,180, 83 );
- For ($ I = 0; $ I $ Font = mt_rand (3, 5 );
- $ X = mt_rand (1, 8) + $ imagewidth * $ I/4;
- $ Y = mt_rand (1, $ imageheight/3 );
- $ Color = imagecolorallocate ($ numimage, mt_rand (0,150), mt_rand (0,255 ));
- Imagestring ($ numimage, $ font, $ x, $ y, $ num [$ I], $ color );
- }
- Imagepng ($ numimage );
- Imagedestroy ($ numimage );
- ?>
-
-
-
- Call method:
- Session_start ();
- Include_once 'Conn/conn. php ';
- $ Pattern = '1234567890abcdefghijklmnopqrstuvwxyzabcdefghijklomnopqrstuvwxyz ';
- $ Num = null;
- For ($ I = 0; $ I <4; $ I ++ ){
- $ Num. = $ pattern {mt_rand (0, 61 )};
- }
- ?>
-
Verification code:
-
- "Width =" 55 "height =" 18 "/>
|
Verification code, writing letters, PHP