Add graphic Verification Code

Source: Internet
Author: User

1. A. php

<? PHP

Session_start ();

Function random ($ Len) { $ Srcstr = "abcdefghijklmnopqrstuvwxyz0123456789 "; Mt_srand (); $ STRs = ""; For ($ I = 0; $ I <$ Len; $ I ++ ){ $ STRs. = $ srcstr [mt_rand (0, 35)]; } Return strtoupper ($ STRs ); } $ STR = random (4); // randomly generated string $ Width = 50; // The image width of the Verification Code $ Height = 25; // height of the Verification Code Image @ Header ("Content-Type: image/PNG "); $ _ Session ["code"] = $ STR; // Echo $ STR; $ Im = imagecreate ($ width, $ height ); // Background color $ Back = imagecolorallocate ($ im, 0xff, 0xff, 0xff ); // Blur the vertex color $ Pix = imagecolorallocate ($ im, 187,230,247 ); // Font color $ Font = imagecolorallocate ($ im, 41,163,238 ); // Plot the vertices of fuzzy match. Mt_srand (); For ($ I = 0; I I <1000; $ I ++) { Imagesetpixel ($ im, mt_rand (0, $ width), mt_rand (0, $ height), $ pix ); } Imagestring ($ im, 5, 7, 5, $ STR, $ font ); Imagerectangle ($ im, 0, 0, $ width-1, $ height-1, $ font ); Imagepng ($ IM ); Imagedestroy ($ IM ); $ _ Session ["code"] = $ STR; ?>

 

 

2. B. php

<? PHP

// Include_once ('identifying. php '); Session_start (); // code for generating the verification code Echo " Echo $ _ session ["code"]; // generate the verification code value ?>

 

Add graphic 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.