PHP graphical Digital validation Code _php tutorial

Source: Internet
Author: User

PHP Graphical Digital Verification Code


The following code I debug all pass. Run authpage.php.



/*

* Filename:authpage.php

*/

Srand (Double) microtime () *1000000);

//Verify user input is consistent with verification code

if (isset ($_post[' authinput ') )

{


if (strcmp ($_post[' authnum '],$_post[' authinput ']) ==0)

echo "verified success! ";

Else

echo "Verification failed! ";

}

//Generate a new four-bit integer verification code

while (($authnum =rand ()%10000) <1000);

?>



----------------------------------------------------------------------------------------------------------- --


/*

* Filename:authimg.php

*/
//Generate Verification code picture
Header ("Content-type:image/png");

Srand (Double) microtime () *1000000);

$im = imagecreate (58,28);

$black = imagecolorallocate ($im, 0,0,0);

$white = imagecolorallocate ($im, 255,255,255);

$gray = imagecolorallocate ($im, 200,200,200);

Imagefill ($im, 68,30, $gray);

//Draw a four-bit integer verification code into the picture

imagestring ($im, 5, 8, $HTTP _get_vars[' Authnum '), $white);

For ($i =0; $i <50; $i + +)//add interfering pixels

{

Imagesetpixel ($im, Rand ()%70, Rand ()%30, $gray);

}

imagepng ($im);

Imagedestroy ($im);

?>
__________________

java->struts

http://www.bkjia.com/PHPjc/845133.html www.bkjia.com true http://www.bkjia.com/PHPjc/845133.html techarticle PHP Graphics Digital Verification Code The following code I debug all pass. Run authpage.php.? /* * Filename:authpage.php */srand (double) microtime () *1000000); Verify that user input is ...

  • 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.