圖形數(shù)字驗(yàn)證代碼
更新時(shí)間:2006年10月09日 00:00:00 作者:
圖形數(shù)字驗(yàn)證代碼 Code: <?
/*
* Filename: authpage.php
*/
srand((double)microtime()*1000000);
//驗(yàn)證用戶輸入是否和驗(yàn)證碼一致
if(isset($_POST['authinput']))
{
if(strcmp($_POST['authnum'],$_POST['authinput'])==0)
echo "驗(yàn)證成功!";
else
echo "驗(yàn)證失??!";
}
//生成新的四位整數(shù)驗(yàn)證碼
while(($authnum=rand()%10000)<1000);
?>
<form action=authpage.php method=post>
<table>
請輸入驗(yàn)證碼:<input type=text name=authinput style="width: 80px"><br>
<input type=submit name="驗(yàn)證" value="提交驗(yàn)證碼">
<input type=hidden name=authnum value=<? echo $authnum; ?>>
<img src=authimg.php?authnum=<? echo $authnum; ?>>
</table>
</form>
-------------------------------------------------------------------------------------------------------------
<?
/*
* Filename: authimg.php
*/
//生成驗(yàn)證碼圖片
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);
//將四位整數(shù)驗(yàn)證碼繪入圖片
imagestring($im, 5, 10, 8, $HTTP_GET_VARS['authnum'], $white);
for($i=0;$i<50;$i++) //加入干擾象素
{
imagesetpixel($im, rand()%70 , rand()%30 , $gray);
}
ImagePNG($im);
ImageDestroy($im);
?>
相關(guān)文章
建立動(dòng)態(tài)的WML站點(diǎn)(二)
建立動(dòng)態(tài)的WML站點(diǎn)(二)...2006-10-10在PHP3中實(shí)現(xiàn)SESSION的功能(二)
在PHP3中實(shí)現(xiàn)SESSION的功能(二)...2006-10-10BS結(jié)構(gòu)中使用PHP訪問ORACLE LOB
這篇文章主要介紹了BS結(jié)構(gòu)中使用PHP訪問ORACLE LOB2006-10-10