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 ???