防止重复提交问题(调试成功结帖)

ewai 2003-08-22 11:42:28
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("new/data/ewai.asp")
buyao=request.form("buyao")
comment=request.form("comment")
strsql="select * from user1 where comment=('comment')"
set rs=server.createobject("adodb.recordset")
rs.open strsql,conn,1,3
if not (rs.eof and rs.eof) then
response.write "你所用的帐号已经存在"
end if
rs.close
set rs=nothing
sql="insert into user1(comment,buyao)values('"+comment+"','"+buyao+"') "
conn.execute sql
conn.close
set conn=nothing
%>
我的意图是从表单里得到buyao,comment的值,如果COMMENT在表里已经存在则显示你所用的帐号已经存在,否则添加入表中,这段代码哪里要更改?
...全文
43 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
danger1 2003-08-22
  • 打赏
  • 举报
回复
变量都用错啦
strsql="select * from user1 where comment=('"&comment&"')"
sql="insert into user1(comment,buyao)values('"&comment&"','"&buyao&"') "
chinesun 2003-08-22
  • 打赏
  • 举报
回复
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("new/data/ewai.asp")
buyao=request.form("buyao")
comment=request.form("comment")
strsql="select * from user1 where comment='"&comment&"'"
set rs=server.createobject("adodb.recordset")
rs.open strsql,conn,3,3
if rs.RecordCount>0 then
response.write "你所用的帐号已经存在"
response.end
else
rs("comment")=comment
rs("buyao")=buyao
rs.update
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
lions911 2003-08-22
  • 打赏
  • 举报
回复
if not (rs.eof and rs.bof) then
response.write "账号已存在"
else
rs.close
set rs.nothing
sql="insert.........................."
conn.execute sql
conn.close
end if
==================
批准、执行
year81s 2003-08-22
  • 打赏
  • 举报
回复
if not (rs.eof and rs.bof) then
response.write "账号已存在"
else
rs.close
set rs.nothing
sql="insert.........................."
conn.execute sql
conn.close
end if

28,391

社区成员

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

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