永发信息网

asp验证表单提交数据是否与数据库重复

答案:2  悬赏:50  手机版
解决时间 2021-02-01 01:10
  • 提问者网友:浩歌待明月
  • 2021-01-31 00:14
部分代码:
bbName = Request.Form("bbName")
jfjl = Request.Form("jfjl")
CatalogName = Request.Form("CatalogName")

Sql = "SELECt * FROM pipfl where CatalogName='"&Request.Form("CatalogName")&"' "
Set Rs = Db.ExeCute2(Sql)
if not rs.eof then
Response.Write(escape(" (此登陆帐号已存在, 请更改!!)</span>"))
end if
rs.close
set rs=nothing
Sql = "Insert Into pipfl(bbName,CatalogName,jfjl) Values('"& bbName &"','"& CatalogName &"','"& jfjl &"')"
Db.ExeCute2(Sql)
Response.Redirect("ProdsCtlg.asp")
不知道为什么验证没有反应!重复的数据还是可以提交上,请高手帮忙!
最佳答案
  • 五星知识达人网友:七十二街
  • 2021-01-31 01:28
bbName = Request.Form("bbName")
jfjl = Request.Form("jfjl")
CatalogName = Request.Form("CatalogName")

Sql = "SELECt * FROM pipfl where CatalogName='"&Request.Form("CatalogName")&"' "
Set Rs = Db.ExeCute2(Sql)
if not rs.eof then
Response.Write(escape(" (此登陆帐号已存在, 请更改!!)</span>"))
else
rs.close
set rs=nothing
Sql = "Insert Into pipfl(bbName,CatalogName,jfjl) Values('"& bbName &"','"& CatalogName &"','"& jfjl &"')"
Db.ExeCute2(Sql)
Response.Redirect("ProdsCtlg.asp")
end if
全部回答
  • 1楼网友:北方的南先生
  • 2021-01-31 01:49
Response.Write(escape(" (此登陆帐号已存在, 请更改!!)</span>")) 后面加上 response.end() 不然会继续执行 或者你用if else end if进行分支。 看得出来你是刚学,你这个程序有注入漏洞,要对Request.Form("CatalogName")进行处理,至少要替换掉单引号。 补充一下,上面那个response.end之前应该关闭记录集和数据库连接池,写程序有好多要注意的。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯