澳门新葡亰娱乐官网图形数字验证代码

目前,不少网站为了防止用户利用机器人自动注册、登录、灌水,都采用了验证码技术。所谓验证码,就是将一串随机产生的数字或符号,生成一幅图片,图片里加上一些干扰象素,由用户肉眼识别其中的验证码信息,输入表单提交网站验证,验证成功后才能使用某项功能。英语学习网我们这里展示了如何编写PHP程序实现验证码功能:代码一:CODE:?php
/* * Filename: authpage.php * Author: hutuworm * Date: 2003-04-28 *
@Copyleft hutuworm.org */ srand((double)microtime()*1000000);
//验证用户输入是否和验证码一致
if(isset($HTTP_POST_VARS[”authinput”])) {
if(strcmp($HTTP_POST_VARS[”authnum”],$HTTP_POST_VARS[”authinput”])==0)
echo 验证成功!; else echo 验证失败!; } //生成新的四位整数验证码
while(($authnum=rand()%10000)1000); ? form action=authpage.php
method=post table 请输入验证码:input type=text name=authinput
style=width: 80pxbrinput type=submit name=验证 value=提交验证码 input
type=hidden name=authnum value=? echo $authnum; ?<

图形数字验证代码Code:?/** Filename:
authpage.php*/srand((double)microtime()*1000000);//验证用户输入是否和验证码一致if(isset($_POST[‘authinput’])){if(strcmp($_POST[‘authnum’],$_POST[‘authinput’])==0)echo
“验证成功!”;elseecho
“验证失败!”;}//生成新的四位整数验证码while(($authnum=rand()%10000)1000);?form
action=authpage.php method=posttable请输入验证码:input type=text
name=authinput brinput 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;$i50;$i++)
//加入干扰象素{imagesetpixel($im, rand()%70 , rand()%30 ,
$gray);}ImagePNG($im);ImageDestroy($im);?

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图