求助:怎么解决表单防刷新问题?

killhuore 2005-12-16 12:04:43
我有个表单是提交到本页面验证的,可是一刷新它就提交一条一模一样的新记录,有什么办法可以防止吗?最好能带代码参考一下。
...全文
150 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
starytx 2005-12-19
  • 打赏
  • 举报
回复
建议把操作数据库放在另外一个页面处理,处理完后再response.redirect回到提交页面
mzhmark 2005-12-19
  • 打赏
  • 举报
回复
保存完数据后利用response.redirect跳转一下就可以了
wangyingdong 2005-12-19
  • 打赏
  • 举报
回复
ASP禁止刷新当前页

方法1:

<%
Dim SplitReflashPage
Dim DoReflashPage
dim shuaxin_time
DoReflashPage=true
shuaxin_time=10
ReflashTime=Now()
if (not isnull(session("ReflashTime"))) and cint(shuaxin_time)>0 and DoReflashPage then
if DateDiff("s",session("ReflashTime"),Now())<cint(shuaxin_time) then
response.write "<META http-equiv=Content-Type content=text/html; charset=gb2312><meta HTTP-EQUIV=REFRESH CONTENT=3>本页面起用了防刷新机制,请不要在<b><font color=ff0000>"&shuaxin_time&"</font></b>秒内连续刷新本页面<BR>正在打开页面,请稍候……"
response.end
else
session("ReflashTime")=Now()
end if
elseif isnull(session("ReflashTime")) and cint(shuaxin_time)>0 and DoReflashPage then
Session("ReflashTime")=Now()
end if
randomize timer
regjm=int(rnd*8998)+1000
%>


方法2:

<%
Dim URL
If DateDiff("s",Request.Cookies("oesun")("vitistime"),Now())<2 Then
URL=Request.ServerVariables("Http_REFERER")
Response.Write("<meta http-equiv=""refresh"" content=""2;URL="&URL&""">")
Response.Write("防刷新,两秒后自动跳转")
Response.End
End IF
Response.Cookies("oesun")("vitistime")=Now()
%>

http://www.dwww.cn/new/2005920222143314.html
wangyingdong 2005-12-19
  • 打赏
  • 举报
回复
<%
 ’强制性刷新随机验证码
 ’让随机验证码每次按IE的后退按钮时,返回登录页面的随即码都自动刷新,
 Response.expires=-1
 Response.AddHeader"pragma","no-cache"
 Response.AddHeader"cache-control","no-store"
%>

wojiaogyp 2005-12-19
  • 打赏
  • 举报
回复
添加之前先判断数据库中有相同的记录么 ,有的话就不执行添加的动作了呗。
ybfqlyq 2005-12-19
  • 打赏
  • 举报
回复
提交時創建一個SESSION,利用SESSIONID判斷
xx123731 2005-12-19
  • 打赏
  • 举报
回复
加验证码进行验证
wj021chen 2005-12-18
  • 打赏
  • 举报
回复
加个验证码吧~~
doxob 2005-12-18
  • 打赏
  • 举报
回复
我也有相同的问题,帮你顶
comszsoft 2005-12-18
  • 打赏
  • 举报
回复
添加一个条件判断是提交到数据库还是提交给本页面验证不就可以了吗?

28,391

社区成员

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

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