教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 图形数字验证代码

图形数字验证代码

发布时间:2016-10-27   编辑:jiaochengji.com
教程集为您提供图形数字验证代码等资源,欢迎您收藏本站,我们将为您提供最新的图形数字验证代码资源

图形数字验证代码
Code:
 
<?
/*
* Filename: authpage.php
*/
srand((double)microtime()*1000000);
//验证用户输入是否和验证码一致
if(isset($_POST['authinput']))
{
if(strcmp($_POST['authnum'],$_POST['authinput'])==0)
echo "验证成功!";
else
echo "验证失败!";
}
//生成新的四位整数验证码
while(($authnum=rand()000)<1000);
?>
<form action=authpage.php method=post>
<table>
请输入验证码:<input type=text name=authinput style="width: 80px"><br>
<input type=submit name="验证" value="提交验证码">
<input type=hidden name=authnum value=<? echo $authnum; ?>>
<img src=authimg.php?authnum=<? echo $authnum; ?>>
</table>
</form>
-------------------------------------------------------------------------------------------------------------
<?
/*
* Filename: authimg.php
*/
//生成验证码图片
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);
//将四位整数验证码绘入图片
imagestring($im, 5, 10, 8, $HTTP_GET_VARS['authnum'], $white);
for($i=0;$i<50;$i ) //加入干扰象素
{
imagesetpixel($im, rand()p , rand()0 , $gray);
}
ImagePNG($im);
ImageDestroy($im);

您可能感兴趣的文章:
图形数字验证代码
php验证码大全(实例分享)
用php生成带有雪花背景的验证码
php点击验证码实时刷新的实现代码
php彩色验证码的简单例子
php验证码的三个实例代码分享
php图片验证码的例子
php生成动态图片验证码的一段代码
python如何识别验证码
发布一个图形数字验证代码

[关闭]
~ ~