防止短时间重复提交留言!

JYJjiayunjie 2009-08-13 04:59:05
代码
session("time")=now()
const a=#0:0:60# '定义相隔之间的秒数
if session("time2") >0 then '如果有值
if session("time2")+a > session("time") then '
session("time2")=now()
response.Write "<script language=javascript> {window.alert('为防止恶意灌水,请您20秒后再留言,谢谢!');window.history.go(-1);}</script>"
response.end
end if
end if
session("time2")=now()
我的留言板的脚本代码
<%

if request("send")="ok" then

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

if request.form("usermail") <> "" 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 BookFeedBack 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='BookWrite.asp';"
response.write "</script>"
response.end

end if

%>
应该把防止重复提交留言的代码放到哪个位置才行??
...全文
84 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
plcc123 2009-08-14
  • 打赏
  • 举报
回复
同理啊
gxq323 2009-08-13
  • 打赏
  • 举报
回复
最前面就行吧
JYJjiayunjie 2009-08-13
  • 打赏
  • 举报
回复
不是那样的,我知道了,现在这个问题不用问了,呵呵
抱抱我的小猫 2009-08-13
  • 打赏
  • 举报
回复
if request("send")="ok" then

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

中间
JYJjiayunjie 2009-08-13
  • 打赏
  • 举报
回复
急啊

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧