救助:为什么添加留言时提交后会添加了2个同样的纪录呢?
请教一下:
我写的留言版程序,为什么添加留言时提交后会添加了2个同样的纪录呢?大家帮我看看,谢谢了!
十分郁闷,刚开始测试的都正常,过了一天就不行了,每次提交后就添加2条纪录.
我用的是WINxp,IE7.0,6.0测试都一样
<!--#include file= "conn.asp "-->
<%
uname=trim(Request.Form( "name "))
sex=trim(Request.Form( "sex "))
if sex= "男 " then
head= "images/boy.gif "
else
head= "images/girl.gif "
end if
city=trim(Request.Form( "city "))
city1=trim(Request.Form( "city1 "))
city=city&city1
qq=trim(Request.Form( "qq "))
email=trim(Request.Form( "email "))
homepage=trim(Request.Form( "homepage "))
infos=trim(Request.Form( "infos "))
set rs=Server.CreateObject( "Adodb.recordset ")
sql= "Select * from gbook "
if uname <> " " then
rs.Open sql,conn,1,3
rs.AddNew
rs( "name ")=uname
rs( "sex ")=sex
rs( "head ")=head
rs( "city ")=city
rs( "email ")=email
rs( "qq ")=qq
rs( "homepage ")=homepage
rs( "infos ")=infos
rs.Update
rs.close
set rs=nothing
closedata
end if
Response.write " <script language= 'javascript '> " & chr(13)
Response.write "alert( '留言成功,谢谢您的支持! '); " & Chr(13)
Response.write "window.document.location.href= 'index.asp '; "&Chr(13)
Response.write " </script> " & Chr(13)
Response.End
%>
------解决方案--------------------保存页没发现错误,估计是提交页的问题,最大的可能是你在onsubmit检查函数里写了form.submit()
------解决方案--------------------好好跟踪检查你的提交逻辑,估计是重复提交造成的
------解决方案--------------------重复提交表单了
js的check 最后是不是加了 form1.submit();? 而且表单中有submit?
------解决方案--------------------document.form1.submit()
改成return(true);