You can use the PHP plot function to implement the simple verification code function.

Source: Internet
Author: User

You can use the PHP plot function to implement the simple verification code function.

Index. php

<? Php // ================================================" use the Drawing Technology to plot the verification code // 1. generates 4 random numbers $ checkCode = ""; for ($ I = 0; $ I <4; $ I ++) {$ checkCode. = dechex (rand (1, 15); // decheck () decimal conversion to hexadecimal format, that is, the number to be displayed on the Verification Code} // 2. saved column session_start (); $ _ SESSION ['checkcode'] = $ checkCode; // 3. create canvas $ image1 = imagecreatetruecolor (100, 30); // create interference and create 20 arcs for ($ j = 0; $ j <30; $ j ++) {imagearc ($ image1, rand (0,100), rand (0, 30), rand (0,100), rand (0, 30), rand (0,360), rand (0,360 ), imagecolorallocate ($ image1, rand (0,155), rand (0,255), rand (0,255);} // 3. create a font color, paste the word $ white = imagecolorallocate ($ image1, 255,255,255); imagestring ($ image1, rand (2, 5), rand (5, 70 ), rand (2, 15), $ checkCode, $ white); // 5. output image or save header ("content-type: image/png"); imagepng ($ image1); // 6. release the resource imagedestroy ($ image1 );

Login. php

Enter the verification code: 

The above is all the content of the simple verification code function implemented by using the PHP drawing function provided by xiaobian. I hope you can provide more support for the help house ~

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.