I posted it before, but the above is just one, which is not easy for everyone to copy and use. So I will repost it here .? Php generates the verification code image Header (Content-type: imageJPEG); srand (double) microtime () * 1000000); $ imimagecreate (255,255); $ greyimagecolorallocate ($ im, 25
I have published it before, but it is only one of the above, so it is not easy for everyone to copy and use. So I will repost it here. ? Php // generate the verification code image Header (Content-type: image/JPEG); srand (double) microtime () * 1000000); $ im = imagecreate (62,25 ); $ gray = imagecolorallocate ($ im, 255,255, 25
I have published it before, but it is only one of the above, so it is not easy for everyone to copy and use. So I will repost it here.
// Generate a verification code Image
Header ("Content-type: image/JPEG ");
Srand (double) microtime () * 1000000 );
$ Im = imagecreate (62,25 );
$ Gray = imagecolorallocate ($ im, 255,255,255); // background color
$ White = imagecolorallocate ($ im, mt_rand (0,200), mt_rand (0,200), mt_rand (0,200); // text color
$ Black = imagecolorallocate ($ im, 0, 0 );
Imagerectangle ($ im, $ black );
// Imagefill ($ im, 60, 23, $ gray );
Echo $ authnum;
$ Authnum = rand );
// Print the four-digit integer verification code into the image
Imagestring ($ im, 5, 20, 5, $ _ SESSION ['check'], $ white );
For ($ I = 0; $ I <500; $ I ++) // Add interference pixels
{
$ Randcolor = imagecolorallocate ($ im, rand (0,255), rand (0,255), rand (0,255 ));
Imagesetpixel ($ im, rand () % 70, rand () % 30, $ randcolor );
}
Imagejpeg ($ im );
Imagedestroy ($ im );
?>