Php verification code project_php tutorial

Source: Internet
Author: User
Php verification code program. The php verification code program is a php verification code program function. The principle is to use the phpgd library to generate random numbers, and then create a session and a digital image, which becomes a graphical verification code. The php verification code program is a php verification code program function. The principle is to use the php gd library to generate random numbers, and then create a session and a digital image, which becomes a graphical verification code.

Php Tutorial verification code program
A php verification code program function. The principle is to use the php gd library to generate a random number, and then create a session and a digital image, which becomes a graphical verification code.
*/

Function fun_code ($ sessionname)
{
Header ("content-type: image/png ");
Session_start ();
$ Authnum_session = '';
// $ Str = 'abcdefghijkmnpqrstuvwxyz1234567890 ';
$ Str = '000000 ';
$ L = strlen ($ str );
For ($ I = 1; $ I <= 4; $ I ++)
{
$ Num = rand (0 L-1 );
$ Authnum_session. = $ str [$ num];
}
$ _ Session [$ sessionname] = $ authnum_session;
Srand (double) microtime () * 1000000 );
$ Im = imagecreate (50, 20 );
$ Black = imagecolorallocate ($ im, 0, 0 );
$ White = imagecolorallocate ($ im, 255,255,255 );
$ Gray = imagecolorallocate ($ im, 200,200,200 );
Imagefill ($ im, 68, 30, $ gray );
For ($ I = 0; $ I <3; $ I ++)
{
Imageline ($ im, rand (), rand (), rand (20, 40), rand (), $ li );
}
Imagestring ($ im, 5, 8, 2, $ authnum_session, $ white );
For ($ I = 0; $ I <90; $ I ++)
{
Imagesetpixel ($ im, rand () % 70, rand () % 30, $ gray );
}
Imagepng ($ im );
Imagedestroy ($ im );
}
Echo fun_code ("code ");

Http://www.bkjia.com/PHPjc/633010.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/633010.htmlTechArticlephp verification code program a php verification code program function, the principle is to use the php gd library and then generate random numbers, and then create a session with a digital picture, it becomes a graphical verification code ....

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.