Php verification code program

Source: Internet
Author: User
The code is as follows: Copy code

Session_start ();
$ Im = imagecreatetruecolor (100,30 );
// Assign color
$ Bg = imagecolorallocate ($ im, 0, 0 );
$ Textcolor = imagecolorallocate ($ im, 255,255,255 );
// Mark the image
For ($ I = 0; $ I <3; $ I ++ ){

$ Te1 = imagecolorallocate ($ instant, rand (0,255), rand (0,255), rand (0,255 ));
Imageline ($ im, 0, rand (0, 15), 100, rand (0, 15), $ te1 );
}
// Print 200 points on the image
For ($ I = 0; I I <200; $ I ++ ){

Imagesetpixel ($ im, rand () % 100, rand () % 30, $ te1 );
}
For ($ I = 0; $ I <4; $ I ++ ){
// Dechex () converts decimal to hexadecimal
$ Rand. = dechex (rand (1, 15 ));
}
$ _ Session [check_pic] = $ rand;
Imagestring ($ im, 5, rand (3,70), rand (3,15), $ rand, $ textcolor );
Header ("content-type: image/jpeg ");
Imagejpeg ($ im );

/*
The purpose of generating verification is to prevent unauthorized user registration. This is a first-class verification program.
*/

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.