Generate a simple php Verification Code

Source: Internet
Author: User
Tags imagejpeg
I posted it before, but the above is just one, which is not easy for everyone to copy and use. So I will repost it here .? Php generates the verification code image Header (Content-type: imageJPEG); srand (double) microtime () * 1000000); $ imimagecreate (255,255); $ greyimagecolorallocate ($ im, 25

I have published it before, but it is only one of the above, so it is not easy for everyone to copy and use. So I will repost it here. ? Php // generate the verification code image Header (Content-type: image/JPEG); srand (double) microtime () * 1000000); $ im = imagecreate (62,25 ); $ gray = imagecolorallocate ($ im, 255,255, 25

I have published it before, but it is only one of the above, so it is not easy for everyone to copy and use. So I will repost it here.

// Generate a verification code Image

Header ("Content-type: image/JPEG ");
Srand (double) microtime () * 1000000 );
$ Im = imagecreate (62,25 );
$ Gray = imagecolorallocate ($ im, 255,255,255); // background color
$ White = imagecolorallocate ($ im, mt_rand (0,200), mt_rand (0,200), mt_rand (0,200); // text color
$ Black = imagecolorallocate ($ im, 0, 0 );
Imagerectangle ($ im, $ black );
// Imagefill ($ im, 60, 23, $ gray );
Echo $ authnum;
$ Authnum = rand );

// Print the four-digit integer verification code into the image
Imagestring ($ im, 5, 20, 5, $ _ SESSION ['check'], $ white );
For ($ I = 0; $ I <500; $ I ++) // Add interference pixels
{
$ Randcolor = imagecolorallocate ($ im, rand (0,255), rand (0,255), rand (0,255 ));
Imagesetpixel ($ im, rand () % 70, rand () % 30, $ randcolor );
}
Imagejpeg ($ im );
Imagedestroy ($ im );


?>

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.