永发信息网

怎么样才能防止刷新,重复添加记录,代码代码怎么写啊?

答案:2  悬赏:0  手机版
解决时间 2021-03-21 16:28
  • 提问者网友:暮烟疏雨之际
  • 2021-03-21 13:19
我的代码如下:

<!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>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 20px;
margin-right: 0px;
margin-bottom: 0px;
}
.STYLE5 {font-size: 14px; }
.STYLE6 {font-size: 14px; font-family: "宋体"; }
.STYLE7 {font-size: 12px; font-family: "宋体"; }
-->
</style></head>

<body>
<form id="form1" name="form1" method="post" action="">
<label>姓名
<input name="name" type="text" id="name" size="8" maxlength="6" />
</label>

<label>tel
<input name="tel" type="text" id="tel" size="13" maxlength="6" />
</label>

<label>QQ
<input name="qq" type="text" id="qq" size="15" maxlength="6" />
</label>
<label>

<input type="submit" name="Submit" value="提交" />
</label>
</form>
<form id="form2" name="form2" method="post" action="">

<%
set conn=server.CreateObject("adodb.connection")
DBPath = Server.MapPath("db1.mdb")
conn.open "provider=microsoft.jet.oledb.4.0; data source="&DBpath
act=request.QueryString("act")
if act="del" then '删除
id=request.QueryString("id")
sql="delete from info where id="&id
conn.execute(sql)
response.Redirect("del.asp")
end if
exec="select * from info ORDER BY id DESC"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
%>
<table width="589" height="8" border="0" cellpadding="5" cellspacing="1" bgcolor="#D6E0EF">
<tr>
<td bgcolor="#698CC3"><div align="center" class="STYLE5">编号</div></td>
<td bgcolor="#698CC3"><div align="center" class="STYLE5">姓名</div></td>
<td bgcolor="#698CC3"><div align="center" class="STYLE6">tel</div></td>
<td bgcolor="#698CC3"><div align="center" class="STYLE6">qq</div></td>
<td bgcolor="#698CC3"><div align="center" class="STYLE7">time</div></td>
<td bgcolor="#698CC3"><div align="center" class="STYLE6">删除</div></td>
<td bgcolor="#698CC3"><div align="center" class="STYLE6">修改</div></td>
</tr>
。。。。。。。。。。。。。。
</html>
最佳答案
  • 五星知识达人网友:孤独入客枕
  • 2021-03-21 13:42
查询一下数据库,where 条件就是你要保存的数据,如果返回的有记录则表示重复<br><br>在exec=&quot;insert into gongshi (cpmc,cplx,gxd,gx,bzgs,bzcl,bbh,scz,sxrq,yxq) values ('&quot;+cpmc+&quot;', '&quot;+cplx+&quot;','&quot;+gxd+&quot;','&quot;+gx+&quot;','&quot;+bzgs+&quot;','&quot;+bzcl+&quot;','&quot;+bbh+&quot;','&quot;+scz+&quot;','&quot;+sxrq+&quot;','&quot;+yxq+&quot;')&quot;<br> 之前执行<br>exec=&quot;select * from user where cpmc='&quot;&amp;cpmc&amp;&quot;'and gx='&quot;&amp;gx&amp;&quot;'&quot;<br>set rs=server.createobject(&quot;adodb.recordset&quot;)<br>rs.open exec,conn,1,1<br><br>If not rs.eof and not rs.eof then  '判断资料是否存在<br>Response.write &quot;&lt;script language=javascript&gt;alert('资料存在');history.go(-1);&lt;/script&gt;&quot;<br>Response.End
全部回答
  • 1楼网友:夜余生
  • 2021-03-21 13:58
通常是在表单中增加一个验证码。这是防无意刷新的简便方法。一刷新,验证码自动更新,处理程序就会检测到验证码不对。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯