| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1525 人关注过本帖
标题:[求助]如何在原有的登陆和提交页面上增加“校验码”的功能呢?
只看楼主 加入收藏
开心人
Rank: 1
等 级:新手上路
帖 子:216
专家分:0
注 册:2005-11-1
收藏
得分:0 
以下是引用做人很低调在2006-11-27 14:11:45的发言:

验证码在网上有很多 楼主可以自己搜索一下
主要的原理就是
产生随即数 用SESSION 保存

在和用户输入的比较。。


我现在就是不知道如何。。“在和用户输入的比较。。”这个怎么做。。。:(,老是不对。。。多谢那么多朋友教学,如果我贴出来。。。结合上面朋友给的“生成数字”程序,如何修改下面的这个才对呢??


——————————————————————————————————————————————————

<!--#include file="dd_conn.asp"-->
<%
if request("send")="ok" then

username=trim(request.form("username"))
usermail=trim(request.form("usermail"))

if username="" or request.form("Comments")="" then
response.write "<script language='javascript'>"
response.write "alert('填写资料不完整,请检查后重新输入!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

if checktxt(request.form("username"))<>request.form("username") then
response.write "<script language='javascript'>"
response.write "alert('您输入的用户名中含有非法字符,请检查后重新输入!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

if mailyes=0 then '邮箱为必填时检查邮箱是否合法

if checktxt(request.form("usermail"))<>request.form("usermail") then
response.write "<script language='javascript'>"
response.write "alert('您输入的邮箱中含有非法字符,请检查后重新输入!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

if Instr(usermail,".")<=0 or Instr(usermail,"@")<=0 or len(usermail)<10 or len(usermail)>50 then
response.write "<script language='javascript'>"
response.write "alert('您输入的电子邮件地址格式不正确,请检查后重新输入!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

end if

if len(request.form("Comments"))>maxlength then
response.write "<script language='javascript'>"
response.write "alert('留言内容太长了,请不要超过"&maxlength&"个字符!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

set rs=Server.CreateObject("ADODB.RecordSet")
sql="select * from Feedback where online='1' order by Postdate desc"
rs.open sql,conn,1,3

rs.Addnew
rs("username")=Request("username")
rs("comments")=Request("comments")
rs("usermail")=Request("usermail")
rs("face")=Request("face")
rs("pic")=Request("pic")
rs("url")=Request("url")
rs("qq")=Request("qq")
view=cstr(view)
if view<>"0" then view="1"
rs("online")=view
rs("IP")=Request.serverVariables("REMOTE_ADDR")
rs.Update
rs.close
set rs=nothing
response.write "<script language='javascript'>"
if view="0" then
response.write "alert('留言提交成功,留言须经管理员审核才能发布。');"
else
response.write "alert('留言提交成功,单击“确定”返回留言列表!');"
end if
response.write "location.href='index.asp';"
response.write "</script>"
response.end
end if
%>

<HTML><HEAD>
<TITLE><%=sitename%></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="description" content="<%=sitename%>">
<meta name="keywords" content="<%=sitename%>">
<link rel="stylesheet" href="book.css" type="text/css">
</HEAD>
<center>
<!--#include file="book_top.asp"-->

<table width="779" border=0 cellspacing=0 cellpadding=0 align=center bgcolor="#FFFFFF" class="grayline">
<tr><td align=center height=50>
<img border=0 src=images/write.gif> &nbsp;&nbsp;&nbsp;&nbsp; <a href=index.asp><img border=0 src=images/read.gif title="我要看留言"></a>
</td></tr>

<tr><td>
<form action=write.asp method=post name="book">
<table cellSpacing="1" borderColorDark="#ffffff" cellPadding="4" width="680" align="center" bgColor="#000000" borderColorLight="#000000" border="0">
<tr bgColor="#ebebeb">
<td width="20%" align=right>您的姓名:</td>
<td ><input type=text name="UserName" size="30" maxlength=16>
<font color="#FF0000">*</font></td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>您的邮箱:</td>
<td ><input type=text name="UserMail" size="30" maxlength=50>
<%if mailyes=0 then%><font color="#FF0000">*</font><%end if%></td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>您的网站:</td>
<td><input type=text value="http://" name="url" size="30" maxlength=100></td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>其它联系方式:</td>
<td><input type=text value="" name="QQ" size="30" maxlength=100> (如QQ、MSN等)</td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>留言内容:<br><font color=red>(<%=maxlength%>字以内)</font></td>
<td><textarea name="Comments" rows="7" cols="66" style="overflow:auto;"></textarea></td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>请选择表情:</td>
<td>
<input type="radio" value="1" name="face" checked><img border=0 src="images/face/face1.gif">
<input type="radio" value="2" name="face"><img border=0 src="images/face/face2.gif">
<input type="radio" value="3" name="face"><img border=0 src="images/face/face3.gif">
<input type="radio" value="4" name="face"><img border=0 src="images/face/face4.gif">
<input type="radio" value="5" name="face"><img border=0 src="images/face/face5.gif">
<input type="radio" value="6" name="face"><img border=0 src="images/face/face6.gif">
<input type="radio" value="7" name="face"><img border=0 src="images/face/face7.gif">
<input type="radio" value="8" name="face"><img border=0 src="images/face/face8.gif">
<input type="radio" value="9" name="face"><img border=0 src="images/face/face9.gif">
<input type="radio" value="10" name="face"><img border=0 src="images/face/face10.gif">
<br>
<input type="radio" value="11" name="face"><img border=0 src="images/face/face11.gif">
<input type="radio" value="12" name="face"><img border=0 src="images/face/face12.gif">
<input type="radio" value="13" name="face"><img border=0 src="images/face/face13.gif">
<input type="radio" value="14" name="face"><img border=0 src="images/face/face14.gif">
<input type="radio" value="15" name="face"><img border=0 src="images/face/face15.gif">
<input type="radio" value="16" name="face"><img border=0 src="images/face/face16.gif">
<input type="radio" value="17" name="face"><img border=0 src="images/face/face17.gif">
<input type="radio" value="18" name="face"><img border=0 src="images/face/face18.gif">
<input type="radio" value="19" name="face"><img border=0 src="images/face/face19.gif">
<input type="radio" value="20" name="face"><img border=0 src="images/face/face20.gif">

</td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>请选择头像:</td>
<td>
<input type="radio" value="1" name="pic" checked><img border=0 src="images/face/pic1.gif" width=60>
<input type="radio" value="2" name="pic"><img border=0 src="images/face/pic2.gif" width=60>
<input type="radio" value="3" name="pic"><img border=0 src="images/face/pic3.gif" width=60>
<input type="radio" value="4" name="pic"><img border=0 src="images/face/pic4.gif" width=60>
<input type="radio" value="5" name="pic"><img border=0 src="images/face/pic5.gif" width=60>
<br>
<input type="radio" value="6" name="pic"><img border=0 src="images/face/pic6.gif" width=60>
<input type="radio" value="7" name="pic"><img border=0 src="images/face/pic7.gif" width=60>
<input type="radio" value="8" name="pic"><img border=0 src="images/face/pic8.gif" width=60>
<input type="radio" value="9" name="pic"><img border=0 src="images/face/pic9.gif" width=60>
<input type="radio" value="10" name="pic"><img border=0 src="images/face/pic10.gif" width=60>
</td>
</tr>
<tr bgColor="#ebebeb">
<td colSpan="2"><input type="submit" value="提交留言" name="Submit">
<input type="reset" value="重新填写" name="Submit2"><input type=hidden name=send value=ok></td>
</tr>
</table>
</form>

</table>

<!--#include file="book_down.asp"-->
</center>
</body>
</html>


——————————————————————————————————————————————————




[此贴子已经被作者于2007-2-6 18:16:04编辑过]


2007-02-06 18:14
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 

if len(request.form("Comments"))>maxlength then
response.write "<script language='javascript'>"
response.write "alert('留言内容太长了,请不要超过"&maxlength&"个字符!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if
'在这个后面加判断如
if request.form("CheckCode")<>session("CheckCode") then
response.write "<script language='javascript'>"
response.write "alert('验证码错误请从新输入验证码');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if
<tr bgColor="#ebebeb">
<td width="20%" align=right>您的姓名:</td>
<td ><input type=text name="UserName" size="30" maxlength=16>
<font color="#FF0000">*</font></td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>验证码:</td>
<td ><input type=text name="CheckCode" size="30" maxlength=16>
<font color="#FF0000">*</font></td>
</tr>
然后在网页的某个位置加入
<img src="[验证码网页的URL]" >
比如验证码网页是VerifyCode.asp则
<img src="VerifyCode.asp" >
这样用户就看见验证码了。

2007-02-06 21:17
开心人
Rank: 1
等 级:新手上路
帖 子:216
专家分:0
注 册:2005-11-1
收藏
得分:0 
多谢版主。。。。。感谢感谢。。。。没有你的举手之劳,我不知道要走多少冤枉路。。。。晚上我就试试。。成功了我第一个上来这里报喜。。。……!#…¥!¥%…!%…!

2007-02-07 17:45
开心人
Rank: 1
等 级:新手上路
帖 子:216
专家分:0
注 册:2005-11-1
收藏
得分:0 

嗯???总是说出错呢??就算是输入码吻合,也提示"验证码错误请从新输入验证码..." 是否是这个判断错了??

if request.form("CheckCode")<>session("CheckCode") then

[此贴子已经被作者于2007-2-8 15:08:17编辑过]


2007-02-08 15:07
开心人
Rank: 1
等 级:新手上路
帖 子:216
专家分:0
注 册:2005-11-1
收藏
得分:0 
应该还是生成码那里的问题吧,能看到码,但是输入进去,总是报错误......:(

2007-02-08 15:16
开心人
Rank: 1
等 级:新手上路
帖 子:216
专家分:0
注 册:2005-11-1
收藏
得分:0 
我在页面测试输出了。。。。。


<%response.write session("CheckCode")%>


发现这个值总等于上一个数。。。。。晕。。。。。

2007-02-08 15:26
xxaxx
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-2-8
收藏
得分:0 
验证码在网上有很多 楼主可以自己搜索一下
主要的原理就是
产生随即数 用SESSION 保存
在和用户输入的比较。。
2007-02-08 16:35
开心人
Rank: 1
等 级:新手上路
帖 子:216
专家分:0
注 册:2005-11-1
收藏
得分:0 
我换了一个生成码的程序,同样出现这样的问题。。。看来应该是。。

if request.form("CheckCode")<>session("CheckCode") then

里的request.form("CheckCode")没有得到数???

2007-02-08 16:56
开心人
Rank: 1
等 级:新手上路
帖 子:216
专家分:0
注 册:2005-11-1
收藏
得分:0 

我这样来改,总是不成功。。。。。。大家帮看看错了吗??


————————————————————————————————————————————————

<!--#include file="dd_conn.asp"-->
<%
if request("send")="ok" then

username=trim(request.form("username"))
usermail=trim(request.form("usermail"))

if username="" or request.form("Comments")="" then
response.write "<script language='javascript'>"
response.write "alert('填写资料不完整,请检查后重新输入!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

if checktxt(request.form("username"))<>request.form("username") then
response.write "<script language='javascript'>"
response.write "alert('您输入的用户名中含有非法字符,请检查后重新输入!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

if mailyes=0 then '邮箱为必填时检查邮箱是否合法

if checktxt(request.form("usermail"))<>request.form("usermail") then
response.write "<script language='javascript'>"
response.write "alert('您输入的邮箱中含有非法字符,请检查后重新输入!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

if Instr(usermail,".")<=0 or Instr(usermail,"@")<=0 or len(usermail)<10 or len(usermail)>50 then
response.write "<script language='javascript'>"
response.write "alert('您输入的电子邮件地址格式不正确,请检查后重新输入!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

end if

if len(request.form("Comments"))>maxlength then
response.write "<script language='javascript'>"
response.write "alert('留言内容太长了,请不要超过"&maxlength&"个字符!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

'在这个后面加判断如
if request.form("CheckCode")<>session("CheckCode") then
response.write "<script language='javascript'>"
response.write "alert('验证码错误请从新输入验证码');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if


set rs=Server.CreateObject("ADODB.RecordSet")
sql="select * from Feedback where online='1' order by Postdate desc"
rs.open sql,conn,1,3

rs.Addnew
rs("username")=Request("username")
rs("comments")=Request("comments")
rs("usermail")=Request("usermail")
rs("face")=Request("face")
rs("pic")=Request("pic")
rs("url")=Request("url")
rs("qq")=Request("qq")
view=cstr(view)
if view<>"0" then view="1"
rs("online")=view
rs("IP")=Request.serverVariables("REMOTE_ADDR")
rs.Update
rs.close
set rs=nothing
response.write "<script language='javascript'>"
if view="0" then
response.write "alert('留言提交成功,留言须经管理员审核才能发布。');"
else
response.write "alert('留言提交成功,单击“确定”返回留言列表!');"
end if
response.write "location.href='index.asp';"
response.write "</script>"
response.end
end if
%>

<HTML><HEAD>
<TITLE><%=sitename%></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="description" content="<%=sitename%>">
<meta name="keywords" content="<%=sitename%>">
<link rel="stylesheet" href="book.css" type="text/css">
</HEAD>
<center>
<!--#include file="dd_book_top.asp"-->

<table width="779" border=0 cellspacing=0 cellpadding=0 align=center bgcolor="#FFFFFF" class="grayline">
<tr><td align=center height=50>
<img border=0 src=images/write.gif> &nbsp;&nbsp;&nbsp;&nbsp; <a href=index.asp><img border=0 src=images/read.gif title="我要看留言"></a>
</td></tr>

<tr><td>
<form action=dd_write.asp method=post name="book">
<table cellSpacing="1" borderColorDark="#ffffff" cellPadding="4" width="680" align="center" bgColor="#000000" borderColorLight="#000000" border="0">
<tr bgColor="#ebebeb">
<td width="20%" align=right>您的姓名:</td>
<td ><input type=text name="UserName" size="30" maxlength=16>
<font color="#FF0000">*</font></td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>您的邮箱:</td>
<td ><input type=text name="UserMail" size="30" maxlength=50>
<%if mailyes=0 then%><font color="#FF0000">*</font><%end if%></td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>您的网站:</td>
<td><input type=text value="http://" name="url" size="30" maxlength=100></td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>其它联系方式:</td>
<td><input type=text value="" name="QQ" size="30" maxlength=100> (如QQ、MSN等)</td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>留言内容:<br><font color=red>(<%=maxlength%>字以内)</font></td>
<td><textarea name="Comments" rows="7" cols="66" style="overflow:auto;"></textarea></td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>请选择表情:</td>
<td>
<input type="radio" value="1" name="face" checked><img border=0 src="images/face/face1.gif">
<input type="radio" value="2" name="face"><img border=0 src="images/face/face2.gif">
<input type="radio" value="3" name="face"><img border=0 src="images/face/face3.gif">
<input type="radio" value="4" name="face"><img border=0 src="images/face/face4.gif">
<input type="radio" value="5" name="face"><img border=0 src="images/face/face5.gif">
<input type="radio" value="6" name="face"><img border=0 src="images/face/face6.gif">
<input type="radio" value="7" name="face"><img border=0 src="images/face/face7.gif">
<input type="radio" value="8" name="face"><img border=0 src="images/face/face8.gif">
<input type="radio" value="9" name="face"><img border=0 src="images/face/face9.gif">
<input type="radio" value="10" name="face"><img border=0 src="images/face/face10.gif">
<br>
<input type="radio" value="11" name="face"><img border=0 src="images/face/face11.gif">
<input type="radio" value="12" name="face"><img border=0 src="images/face/face12.gif">
<input type="radio" value="13" name="face"><img border=0 src="images/face/face13.gif">
<input type="radio" value="14" name="face"><img border=0 src="images/face/face14.gif">
<input type="radio" value="15" name="face"><img border=0 src="images/face/face15.gif">
<input type="radio" value="16" name="face"><img border=0 src="images/face/face16.gif">
<input type="radio" value="17" name="face"><img border=0 src="images/face/face17.gif">
<input type="radio" value="18" name="face"><img border=0 src="images/face/face18.gif">
<input type="radio" value="19" name="face"><img border=0 src="images/face/face19.gif">
<input type="radio" value="20" name="face"><img border=0 src="images/face/face20.gif">

</td>
</tr>
<tr bgColor="#ebebeb">
<td width="20%" align=right>请选择头像:</td>
<td>
<input type="radio" value="1" name="pic" checked><img border=0 src="images/face/pic1.gif" width=60>
<input type="radio" value="2" name="pic"><img border=0 src="images/face/pic2.gif" width=60>
<input type="radio" value="3" name="pic"><img border=0 src="images/face/pic3.gif" width=60>
<input type="radio" value="4" name="pic"><img border=0 src="images/face/pic4.gif" width=60>
<input type="radio" value="5" name="pic"><img border=0 src="images/face/pic5.gif" width=60>
<br>
<input type="radio" value="6" name="pic"><img border=0 src="images/face/pic6.gif" width=60>
<input type="radio" value="7" name="pic"><img border=0 src="images/face/pic7.gif" width=60>
<input type="radio" value="8" name="pic"><img border=0 src="images/face/pic8.gif" width=60>
<input type="radio" value="9" name="pic"><img border=0 src="images/face/pic9.gif" width=60>
<input type="radio" value="10" name="pic"><img border=0 src="images/face/pic10.gif" width=60>
</td>
</tr>
<tr bgColor="#ebebeb"><td align="right">输入右边的校验码:</td>
<td><input type=text name="CheckCode" size="20" maxlength=16>&nbsp;&nbsp;<img src="dd_ma.asp">
&nbsp;&nbsp;<input type="submit" value="提交留言" name="Submit">
<input type="reset" value="重新填写" name="Submit2"><input type=hidden name=send value=ok>

</td>
</tr>
</table>
</form>

</table>

<!--#include file="dd_book_down.asp"-->
</center>
</body>
</html>


————————————————————————————————————————————————————

总是提示:校验码错误。。


2007-02-08 22:03
开心人
Rank: 1
等 级:新手上路
帖 子:216
专家分:0
注 册:2005-11-1
收藏
得分:0 
麻烦哟......有朋友告诉我吗??

2007-02-12 12:39
快速回复:[求助]如何在原有的登陆和提交页面上增加“校验码”的功能呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.047613 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved