您的位置:首页 > 编程语言 > ASP

ASP生成图形(数字验证码)

2007-12-08 10:40 253 查看
<script type="text/javascript"><!--
google_ad_client = "pub-4490194096475053";
/* 内容页,300x250,第一屏 */
google_ad_slot = "3685991503";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>getverifycode.asp

<% dim getrandom
Randomize 
getrandom=mid((rnd*100000),1,4) ''生成6位随机数,取高4位
Session("verifycode")=getrandom ''保存于Session中
%>  

<input name="code" type="text"  id="code" value=""/><%=session("verifycode")%><img src="images/<%=mid(Session("verifycode"),1,1)%>.gif" width="15"><img src="images/<%=mid(Session("verifycode"),2,1)%>.gif" width="15"><img src="images/<%=mid(Session("verifycode"),3,1)%>.gif" width="15"><img src="images/<%=mid(Session("verifycode"),4,1)%>.gif" width="15">

<%usercode=Request("code")
if usercode<>session("verifycode") then
Response.Redirect("verror.asp")
else
response.Write(11)
end if%>

需要注意的是验证码最后一段,就是比较的不能和include放一起,因为会重新include一次就是说肯定会不一样。

另外,这个可以用图片,也可以用数字,用图片的话要0-9的数字。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息