如何给ASP网站加入验证码完全点的

如何给ASP网站加入验证码完全点的

1、index.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form action="submit.asp" method="post" name="form1">

请输入验证码<input type="text" value="" name="yanzheng" />
<img src="yanzhengma.asp">
<input type="submit" />
</form>
</body>
</html>

2、yanzhengma.asp
<%
Call Com_CreatValidCode("ValidCode")
Sub Com_CreatValidCode(pSN)
Response.Expires = -9999
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-ctrol","no-cache"
Response.ContentType = "Image/BMP"
Randomize
Dim i, ii, iii
Const cOdds = 8 '杂点出现的机率
Const cAmount = 10 '文字数量
Const cCode = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
'颜色的数据(字符,背景)
Dim vColorData(1)
vColorData(0) = ChrB(0) & ChrB(0) & ChrB(255) '蓝0,绿0,红0(黑色)
vColorData(1) = ChrB(235) & ChrB(235) & ChrB(235) '蓝250,绿236,红211(浅蓝色)
'随机产生字符
Dim vCode(4), vCodes
For i = 0 To 3
vCode(i) = Int(Rnd * cAmount)
vCodes = vCodes & Mid(cCode, vCode(i) + 1, 1)
Next
session("ddyanzheng")=vCodes '记录入Session
'字符的数据
Dim vNumberData(35)
vNumberData(0) = "1110000111110111101111011110111101001011110100101111010010111101001011110111101111011110111110000111"
vNumberData(1) = "1111011111110001111111110111111111011111111101111111110111111111011111111101111111110111111100000111"
vNumberData(2) = "1110000111110111101111011110111111111011111111011111111011111111011111111011111111011110111100000011"
vNumberData(3) = "1110000111110111101111011110111111110111111100111111111101111111111011110111101111011110111110000111"
vNumberData(4) = "1111101111111110111111110011111110101111110110111111011011111100000011111110111111111011111111000011"
vNumberData(5) = "1100000011110111111111011111111101000111110011101111111110111111111011110111101111011110111110000111"
vNumberData(6) = "1111000111111011101111011111111101111111110100011111001110111101111011110111101111011110111110000111"
vNumberData(7) = "1100000011110111011111011101111111101111111110111111110111111111011111111101111111110111111111011111"
vNumberData(8) = "1110000111110111101111011110111101111011111000011111101101111101111011110111101111011110111110000111"
vNumberData(9) = "1110001111110111011111011110111101111011110111001111100010111111111011111111101111011101111110001111"
vNumberData(10) = "1111011111111101111111101011111110101111111010111111101011111100000111110111011111011101111000100011"
vNumberData(11) = "1000000111110111101111011110111101110111110000111111011101111101111011110111101111011110111000000111"
vNumberData(12) = "1110000011110111101110111110111011111111101111111110111111111011111111101111101111011101111110001111"
vNumberData(13) = "1000001111110111011111011110111101111011110111101111011110111101111011110111101111011101111000001111"
vNumberData(14) = "1000000111110111101111011011111101101111110000111111011011111101101111110111111111011110111000000111"
vNumberData(15) = "1000000111110111101111011011111101101111110000111111011011111101101111110111111111011111111000111111"
vNumberData(16) = "1110000111110111011110111101111011111111101111111110111111111011100011101111011111011101111110001111"
vNumberData(17) = "1000100011110111011111011101111101110111110000011111011101111101110111110111011111011101111000100011"
vNumberData(18) = "1100000111111101111111110111111111011111111101111111110111111111011111111101111111110111111100000111"
vNumberData(19) = "1110000011111110111111111011111111101111111110111111111011111111101111111110111110111011111000011111"
vNumberData(20) = "1000100011110111011111011011111101011111110001111111010111111101101111110110111111011101111000100011"
vNumberData(21) = "1000111111110111111111011111111101111111110111111111011111111101111111110111111111011110111000000011"
vNumberData(22) = "1000100011110010011111001001111100100111110101011111010101111101010111110101011111010101111001010011"
vNumberData(23) = "1000100011110011011111001101111101010111110101011111010101111101100111110110011111011001111000110111"
vNumberData(24) = "1110001111110111011110111110111011111011101111101110111110111011111011101111101111011101111110001111"
vNumberData(25) = "1000000111110111101111011110111101111011110000011111011111111101111111110111111111011111111000111111"
vNumberData(26) = "1110001111110111011110111110111011111011101111101110111110111011111011101001101111011001111110001011"
vNumberData(27) = "1000001111110111011111011101111101110111110000111111010111111101101111110110111111011101111000110011"
vNumberData(28) = "1110000011110111101111011110111101111111111001111111111001111111111011110111101111011110111100000111"
vNumberData(29) = "1000000011101101101111110111111111011111111101111111110111111111011111111101111111110111111110001111"
vNumberData(30) = "1000100011110111011111011101111101110111110111011111011101111101110111110111011111011101111110001111"
vNumberData(31) = "1000100011110111011111011101111101110111111010111111101011111110101111111010111111110111111111011111"
vNumberData(32) = "1001010011110101011111010101111101010111110101011111001001111110101111111010111111101011111110101111"
vNumberData(33) = "1000100011110111011111101011111110101111111101111111110111111110101111111010111111011101111000100011"
vNumberData(34) = "1000100011110111011111011101111110101111111010111111110111111111011111111101111111110111111110001111"
vNumberData(35) = "1100000011110111011111111101111111101111111110111111110111111111011111111011111111101110111100000011"
'输出图像文件头
Response.BinaryWrite ChrB(66) & ChrB(77) & ChrB(230) & ChrB(4) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) &_
ChrB(0) & ChrB(0) & ChrB(54) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(40) & ChrB(0) &_
ChrB(0) & ChrB(0) & ChrB(40) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(10) & ChrB(0) &_
ChrB(0) & ChrB(0) & ChrB(1) & ChrB(0)
'输出图像信息头
Response.BinaryWrite ChrB(24) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(176) & ChrB(4) &_
ChrB(0) & ChrB(0) & ChrB(18) & ChrB(11) & ChrB(0) & ChrB(0) & ChrB(18) & ChrB(11) &_
ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) &_
ChrB(0) & ChrB(0)
For i = 9 To 0 Step -1 '历经所有行
For ii = 0 To 3 '历经所有字
For iii = 1 To 10 '历经所有像素
'逐行、逐字、逐像素地输出图像数据
If Rnd * 99 + 1 < cOdds Then '随机生成杂点
Response.BinaryWrite vColorData(0)
Else Response.BinaryWrite vColorData(Mid(vNumberData(vCode(ii)), i * 10 + iii, 1))
End If
Next
Next
Next
End Sub%>
3、在submit.asp验证验证码输入的是否正确
<%if trim(server.HTMLEncode(Request.Form("yanzheng"))) <> session("ddyanzheng") then
response.Write("验证码不正确")
'response.Redirect("index.asp")
else
response.Write("ok")
end if
%>
温馨提示:内容为网友见解,仅供参考
第1个回答  2010-05-06
要做验证码,首先要有一个获取验证码的文件,这个文件一般命名为getcode.asp或者其他的,这样的文件一般不用我们自己写,随便找一个下载下来就可以了,比如楼上的就是这样的一个文件.
然后在你需要显示验证码的地方,这样写就可以了.
<img src="inc/getcode.asp" alt="验证码,看不清楚?请点击刷新验证码" height="10" onClick="this.src='Inc/getcode.asp'" />
看到了吗?用一个img来加械这个getcode.asp页面,就自动的产生验证码了.
第2个回答  2010-05-06
新建一个verifycode.asp文件,里面的代码为下面的:
<%
Response.Expires=0
Dim RndNumber,RndNumberStr,N,Rs,site_verCookies
If RndNumber = "" or isNumeric(RndNumber) = 0 Then RndNumber = 0
If RndNumber = 0 Then
RndNumber = (Fix(Timer) mod 9999) * 999
End If
RndNumberStr = Right("000" & RndNumber,4)
Session("Verifycode") = RndNumberStr
DisplayBMP
'*****************************************************************
' 验证码显示函数
'*****************************************************************
Sub DisplayBMP
Response.Expires = -9999
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-ctrol","no-cache"
Response.ContentType = "Image/BMP"

Randomize

Dim i, ii, iii

Const cOdds = 3 '杂点出现几率
Const cAmount = 36 ' 文字数量
Const cCode = "0123456789"

Dim vColorData(1)
vColorData(0) = ChrB(0) & ChrB(0) & ChrB(0) ' 蓝0,绿0,红0(黑色)
vColorData(1) = ChrB(255) & ChrB(255) & ChrB(255) ' 蓝250,绿236,红211(浅蓝色)

Dim vCode(4)
For i = 0 To 3
vCode(i) = Mid(RndNumberStr,i + 1,1)
Next

Dim ND(35)
ND(0) = "1110000111110111101111011110111101001011110100101111010010111101001011110111101111011110111110000111"
ND(1) = "1111011111110001111111110111111111011111111101111111110111111111011111111101111111110111111100000111"
ND(2) = "1110000111110111101111011110111111111011111111011111111011111111011111111011111111011110111100000011"
ND(3) = "1110000111110111101111011110111111110111111100111111111101111111111011110111101111011110111110000111"
ND(4) = "1111101111111110111111110011111110101111110110111111011011111100000011111110111111111011111111000011"
ND(5) = "1100000011110111111111011111111101000111110011101111111110111111111011110111101111011110111110000111"
ND(6) = "1111000111111011101111011111111101111111110100011111001110111101111011110111101111011110111110000111"
ND(7) = "1100000011110111011111011101111111101111111110111111110111111111011111111101111111110111111111011111"
ND(8) = "1110000111110111101111011110111101111011111000011111101101111101111011110111101111011110111110000111"
ND(9) = "1110001111110111011111011110111101111011110111001111100010111111111011111111101111011101111110001111"
ND(10) = "1111011111111101111111101011111110101111111010111111101011111100000111110111011111011101111000100011"
ND(11) = "1000000111110111101111011110111101110111110000111111011101111101111011110111101111011110111000000111"
ND(12) = "1110000011110111101110111110111011111111101111111110111111111011111111101111101111011101111110001111"
ND(13) = "1000001111110111011111011110111101111011110111101111011110111101111011110111101111011101111000001111"
ND(14) = "1000000111110111101111011011111101101111110000111111011011111101101111110111111111011110111000000111"
ND(15) = "1000000111110111101111011011111101101111110000111111011011111101101111110111111111011111111000111111"
ND(16) = "1110000111110111011110111101111011111111101111111110111111111011100011101111011111011101111110001111"
ND(17) = "1000100011110111011111011101111101110111110000011111011101111101110111110111011111011101111000100011"
ND(18) = "1100000111111101111111110111111111011111111101111111110111111111011111111101111111110111111100000111"
ND(19) = "1110000011111110111111111011111111101111111110111111111011111111101111111110111110111011111000011111"
ND(20) = "1000100011110111011111011011111101011111110001111111010111111101101111110110111111011101111000100011"
ND(21) = "1000111111110111111111011111111101111111110111111111011111111101111111110111111111011110111000000011"
ND(22) = "1000100011110010011111001001111100100111110101011111010101111101010111110101011111010101111001010011"
ND(23) = "1000100011110011011111001101111101010111110101011111010101111101100111110110011111011001111000110111"
ND(24) = "1110001111110111011110111110111011111011101111101110111110111011111011101111101111011101111110001111"
ND(25) = "1000000111110111101111011110111101111011110000011111011111111101111111110111111111011111111000111111"
ND(26) = "1110001111110111011110111110111011111011101111101110111110111011111011101001101111011001111110001011"
ND(27) = "1000001111110111011111011101111101110111110000111111010111111101101111110110111111011101111000110011"
ND(28) = "1110000011110111101111011110111101111111111001111111111001111111111011110111101111011110111100000111"
ND(29) = "1000000011101101101111110111111111011111111101111111110111111111011111111101111111110111111110001111"
ND(30) = "1000100011110111011111011101111101110111110111011111011101111101110111110111011111011101111110001111"
ND(31) = "1000100011110111011111011101111101110111111010111111101011111110101111111010111111110111111111011111"
ND(32) = "1001010011110101011111010101111101010111110101011111001001111110101111111010111111101011111110101111"
ND(33) = "1000100011110111011111101011111110101111111101111111110111111110101111111010111111011101111000100011"
ND(34) = "1000100011110111011111011101111110101111111010111111110111111111011111111101111111110111111110001111"
ND(35) = "1100000011110111011111111101111111101111111110111111110111111111011111111011111111101110111100000011"

' 输出图像文件头
Response.BinaryWrite ChrB(66) & ChrB(77) & ChrB(230) & ChrB(4) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) &_
ChrB(0) & ChrB(0) & ChrB(54) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(40) & ChrB(0) &_
ChrB(0) & ChrB(0) & ChrB(40) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(10) & ChrB(0) &_
ChrB(0) & ChrB(0) & ChrB(1) & ChrB(0)

' 输出图像信息头
Response.BinaryWrite ChrB(24) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(176) & ChrB(4) &_
ChrB(0) & ChrB(0) & ChrB(18) & ChrB(11) & ChrB(0) & ChrB(0) & ChrB(18) & ChrB(11) &_
ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) &_
ChrB(0) & ChrB(0)

For i = 9 To 0 Step -1
For ii = 0 To 3
For iii = 1 To 10
If Rnd * 99 + 1 < cOdds Then
Response.BinaryWrite vColorData(0)
Else
Response.BinaryWrite vColorData(Mid(ND(vCode(ii)), i * 10 + iii, 1))
End If
Next
Next
Next
End Sub
%>
然后在你需要验证码的地方用下面的方法
<tr>
<td height="30" align="right">验证码:</td>
<td height="30"><input type=text name="verifycode" maxLength=4 size="6" tabindex="3" class="textbox" alt="请在此输入验证码,看不清楚请点击图片刷新">
<font color=red> <-请输入验证码</font> <IMG width="50" height="21" style="cursor:hand;" src="verifycode.asp?n=<%=Timer%>" onClick="this.src=this.src;" align="absmiddle" alt="看不清楚,点击图片刷新"></td>
</tr>

验证函数为下面的:
<%
if Trim(Request.Form("Verifycode"))<>Trim(Session("Verifycode")) then
%>
<script language=javascript>
alert('您输入的认证码不对,请重新输入!')
window.history.go(-1)
</script>
<%
response.end
end if
%>本回答被提问者采纳

如何给ASP网站加入验证码完全点的
无标题文档 请输入验证码 2、yanzhengma.asp < Call Com_CreatValidCode("ValidCode")Sub Com_CreatValidCode(pSN)Response.Expires = -9999 Response.AddHeader "Pragma","no-cache"Response.AddHeader "cache-ctrol","no-cache"Response.ContentType = "Image\/BMP"Randomize ...

ASP网站留言页面如何加入验证码,并进行判断
用函数rnd()随机生成一个数字,然后记录到session中,留言的时候用提交过来的字符验证码与session中的字符进行匹配(记得将数字转换成字符再比较),匹配正确的,就是验证码正确了. 留言成功之后,记得清除验证码session值.

asp网站,注册会员,点击按钮获取手机验证码。短信接口怎么实现?
1. 定义短信服务的URL。2. 构建请求的参数,包括用户身份标识、账号、密码和接收者手机号。3. 创建一个XMLHTTP请求对象。4. 设置请求的类型为POST,并指定请求的URL。5. 为请求设置正确的HTTP头信息。6. 发送请求,并传递构建好的参数。请注意,由于代码片段不完整,并且缺少了具体的错误处理和返回值...

怎样在自己的网页中加入验证码
还不照样要输入验证码)1.给个例子,学习一下吧1.建三个文件 index.asp indexchk.asp code.asp2. index.asp程序 function info_onsubmit(){ var frm = document.reginfo; if (frm.getcode.value==""){ alert("请填写验证码!"); frm.getcode.focus(); return false; } reginfo.submit()...

ASP网页表单怎么添加验证码?
需要一个draw的方法,然后一个随机数,将随机数和draw的返回值绑定

网站后台登录如何加入验证码啊。。以下是我的登录文件。
你从网上下个asp验证码文件,然后在你的验证码处调用,在登录验证页面通过验证就行,验证代码根据你下的asp验证码文件里的程序写,一般是通过session验证。附常用调用和验证 验证码文件名:code.asp,验证session:Session("GetCode"),验证码文本框名:CodeStr 验证码调用: 验证函数:Function codepass(...

怎么在asp留言板中添加验证码
.gif>"> 这就是一个简单的 带验证码的登录界面 上面有具体的代码 但是 图片就得你自己去下了!!!希望能帮你

网站想要加入验证码功能.
先比如10张很小的图片,最好是人能看清楚就可以了。编号为0-9。很快的,图片的容量一张只有120字节。10张也就1K多一点。Randomize number=int(10*rnd)'在0-9中随机取一数 session("number")=number\/设置SESSION值src="...\/<%=session("number")%>.gif">'显示验证码图片。以下是登录页面(...

asp如何实现短信验证码?
1,找个短信代发平台,申请账号注册,有的有测试短信条数,有的没有需要先充值 2,正规平台都有api接口,找到api,阅读文档开发api签入到你自己的网站 3,网站先生成一个验证码通过短信平台发送到指定的手机上 4,收到验证码后输入验证码就可以与发送的验证码作比较了 5,比较一般都在服务器端比较,...

ASP网站如何加入代码直接后台登陆
1、把所有登陆验证的代码删掉 2、验证页面 session("admin")=trim(rs("admin")) ‘用户名 session("flag")=int(rs("flag")) ’可能是权限标志 直接赋值为数据表中对应字段值,admin、flag,前面的一系列验证代码都可以去掉了 楼主”如何加入代码直接后台登陆“这句话是什么意思?是不验证...

相似回答