PHP login page verification code implementation

Source: Internet
Author: User
For PHP login page verification code implementation, open Dreamweaver cs6 and create a PHP site:

Create a new file named 111. php and double-click edit to clear the HTML code automatically generated by Dreamweaver, as shown below;

Add the PHP code in the Dreamweaver CS6 editor as follows:

Session_start ();

Header ("Content-Type: image/png"); // Set the header information of the page to png image $ im = imagecreate (60, 20); // Create a canvas

$ Im_color = imagecolorallocate ($ im, 100,100,100); // fill in the verification code. The background is gray.

For ($ I = 0; $ I <4; $ I ++)

{

$ Line_color = imagecolorallocate ($ im, rand (0,255), rand (0,255), rand (0,255 ));

Imageline ($ im, rand (), $ line_color );

}

// Draw four random interference lines in a practical cycle

$ N = rand );

$ _ SESSION ["y"] = $ n;

$ P = 0;


For ($ I = 0; $ I <4; $ I ++)

{

$ P = $ p + 10;

$ Num = substr ($ n, $ I, 1); // Obtain the verification code numbers one by one.

$ Num_color = imagecolorallocate ($ instant, rand (0,255), rand (0,255), rand (0,255 ));

Imagettftext ($ im, rand (10, 15), rand (-10, 10), $ p, rand (10, 15), $ num_color, "font1.ttf", $ num );


}

// Set the color, angle deviation, and font of each verification code number.

Imagepng ($ im); // output the verification code

Imagedestroy ($ im); // release memory

?>

Then,

Create a login. php file;

The nickname of the username text box is name;

The password text box is; you can write it as needed

The verification code is. you can write it as needed.

Form submission method is post and submitted to check. php.

End

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.