Check if my registration code is not displayed. Display as Red Cross. Who can help solve this problem? & Lt ;? Php *** & nbsp; TestGuest & nbsp; Version1.0 * & nbsp; Copy & nbsp; 2010-2012 & nbsp; y60* & nbsp; Web: & nbsp; htt to see if my registration code is not displayed. Display as Red Cross. Who can help solve this problem?
/**
* TestGuest Version1.0
* ===================================================== ==========
* Copy 2010-2012 y600.
* Web: http://www.yc60.com
* ===================================================== ==========
* Author: Lee
* Date: 2010-8-13
*/
Session_start ();
// Number of random codes
$ _ Rnd_code = 4;
// Create a random code
For ($ I = 0; $ I <$ _ rnd_code; $ I ++ ){
$ _ Nmsg. = dechex (mt_rand (0, 15 ));
}
// Save it in session
$ _ SESSION ['code'] =$ _ nmsg;
// Length and height
$ _ Width = 75;
$ _ Height = 25;
// Create an image
$ _ Img = imagecreatetruecolor ($ _ width, $ _ height );
// White
$ _ White = imagecolorallocate ($ _ img, 255,255,255 );
// Fill
Imagefill ($ _ img, 0, 0, $ _ white );
$ _ Flag = false;
If ($ _ flag ){
// Black, border
$ _ Black = imagecolorallocate ($ _ img, 0, 0 );
Imagerectangle ($ _ img, 0, 0, $ _ width-1, $ _ height-1, $ _ black );
}
// Draw 6 lines.
For ($ I = 0; $ I <6; $ I ++ ){
$ _ Rnd_color = imagecolorallocate ($ _ img, mt_rand (0,255), mt_rand (0,255), mt_rand (0,255 ));
Imageline ($ _ img, mt_rand (0, $ _ width), mt_rand (0, $ _ height), mt_rand (0, $ _ width), mt_rand (0, $ _ height), $ _ rnd_color );
}
// Snowflake
For ($ I = 0; I I <100; $ I ++ ){
$ _ Rnd_color = imagecolorallocate ($ _ img, mt_rand (200,255), mt_rand (200,255), mt_rand (200,255 ));
Imagestring ($ _ img, 1, mt_rand (1, $ _ width), mt_rand (1, $ _ height), '*', $ _ rnd_color );
}
// Output the verification code
For ($ I = 0; $ I
$ _ Rnd_color = imagecolorallocate ($ _ img, mt_rand (0,100), mt_rand (0,150), mt_rand (0,200 ));
Imagestring ($ _ img, 5, $ I * $ _ width/$ _ rnd_code + mt_rand (1, 10), mt_rand (1, $ _ height/2 ), $ _ SESSION ['code'] [$ I], $ _ rnd_color );
}
// Output image
Header ('content-Type: image/png ');
Imagepng ($ _ img );
// Destroy
Imagedestroy ($ _ img );
?>
Is there a high person?
Color
Share:
------ Solution --------------------
Isn't it a direct include?
To be written in the form
In addition, session_start is required for external php.