Php generates a random verification code. What should I do?
Source: Internet
Author: User
Php generates a random verification code. For ($ I = 0; $ I & lt; 4; $ I ++) {& nbsp; $ rand. = dechex (rand ();} // set the image size $ im = imagecreatetruecolor (); // set the color $ bg = imagecolorallocate (php generates a random verification code.
For ($ I = 0; $ I <4; $ I ++ ){
$ Rand. = dechex (rand (1, 15 ));
}
// Set the image size
$ Im = imagecreatetruecolor (100,30 );
// Set the color
$ Bg = imagecolorallocate ($ im, 0, 0 );
$ Te = imagecolorallocate ($ im, 255,255,255 );
// Write the string on the image
Imagestring ($ im, rand (), $ rand, $ te );
// Output image
Header ("Content-type: image/jpeg ");
Imagejpeg ($ im );
?>
Why does the image show a red cross ..
Gd Library opened
------ Solution --------------------
Discussion
How can I solve this problem? $ _ SESSION [check] = $ rand; it is useful to comment out. why?
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