Home > Backend Development > PHP Tutorial > Publish a graphical number verification code_PHP tutorial

Publish a graphical number verification code_PHP tutorial

WBOY
Release: 2016-07-13 17:12:18
Original
782 people have browsed it

The following codes all passed my debugging. Run authpage.php.
/*
* Filename: authpage.php
*/
srand((double)microtime()*1000000);
//Verify whether the user input is consistent with The verification code is consistent
if(isset($_POST['uthinput']))
{
if(strcmp($_POST['authnum'],$_POST['authnum'])==0)
echo "Verification successful!";
else
echo "Verification failed!";
}
//Generate a new four-digit integer verification code
while(($authnum= rand()%10000)<1000);
?>



Please enter the verification code:


>
>


---------------------------------------- -------------------------------------------------- -----------------------
/*
* Filename: authimg.php
*/
//Generate verification code image
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 the four-digit integer verification code into the image
imagestring($im, 5, 10, 8, $HTTP_GET_VARS['authnum'], $white );
for($i=0;$i<50;$i++) //Add interference pixels
{
imagesetpixel($im, rand()%70, rand()%30, $gray);
}
ImagePNG($im);
ImageDestroy($im);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629496.htmlTechArticleI debugged all the following codes and passed them. Run authpage.php. ? /* * Filename: authpage.php */ srand((double)microtime()*1000000); //Verify whether the user input is consistent with the verification code if(iss...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template