Check if my registration code is not displayed. Display as Red Cross. Which expert can help solve the problem?-php Tutorial

Source: Internet
Author: User
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.

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.