Javascript verification for php image verification code-php Tutorial

Source: Internet
Author: User
The php image verification code was last verified by cyyjm in 2013-08-1511: 48: 37 using javascript. now, my image verification is submitted to the background for verification, which affects the query speed. How can I pass it to javascript for verification? The php page generation code is as follows: & lt ;? Php & nbsp; session_start (); & nbsp; generate verification code Image & nbsp; Hea php image verification code verified by javascript

This post was last edited by cyyjm at 11:48:37

Now, my image verification is submitted to the backend for verification, which affects the query speed. How can I pass it to javascript for verification?
The php page generation code is as follows:

Session_start ();
// Generate a verification code Image
Header ("Content-type: image/PNG ");
$ Im = imagecreate (); // draw an image with the specified width and height
$ Back = ImageColorAllocate ($ im, 245,245,245); // defines the background color.
Imagefill ($ im, $ back); // fill the background color in the image you just Drew
$ Vcodes = "";
Srand (double) microtime () * 1000000 );
// Generate four digits
For ($ I = 0; $ I <4; $ I ++ ){
$ Font = ImageColorAllocate ($ im, rand (100,255), rand (0,100), rand (100,255); // Generate a random color
$ Authnum = rand (1, 9 );
$ Vcodes. = $ authnum;
Imagestring ($ im, 5, 2 + $ I * 10, 1, $ authnum, $ font );
}
$ _ SESSION ['vcode'] = $ vcodes;
For ($ I = 0; $ I <100; $ I ++) // add interference pixels
{
$ Randcolor = ImageColorallocate ($ im, rand (0,255), rand (0,255), rand (0,255 ));
Imagesetpixel ($ im, rand () % 70, rand () % 30, $ randcolor); // draws the pixel point function
}
ImagePNG ($ im );
ImageDestroy ($ im );
?>


Foreground style:



In this way, you can enable session_start (); and check whether the verification code is correct with $ _ SESSION ['vcode.
How can I use javascript for verification without the php background for verification.

Share:


------ Solution --------------------
Verification that all users can perform is unreliable.
------ Solution --------------------
Verify through javascript ???

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.