用密码删除纪录

microcoy 2008-12-04 09:09:54
我在前台的一条记录中用form名称为password的文本框(文本框名称也为password),让使用者输入密码,然后通过数据库中由记录添加者输入的密码进行对比,如果正确,删除纪录,如果正确返回,我的代码为:
<%
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from SMT_house"
rs.open sql,conn,1,3
rs("SMT_password")=pw
if pw=request("password") then
Sql="delete from SMT_house where SMT_password="&Request.Form("password")
rs.close
set rs=nothing
end if
%>
可是总删除不了??
不只为什么?
...全文
98 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
sy_binbin 2008-12-04
  • 打赏
  • 举报
回复
<%
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from SMT_house"
rs.open sql,conn,1,3
pw=rs("SMT_password")
if pw=request("password") then
response.write "密码不正确"
response.end
Sql1="delete from SMT_house where SMT_password='"&Request.Form("password")&"'"
conn.execute(sql1)
rs.close
set rs=nothing
end if
%>

看看你页面输入的是什么?
如果是“密码不正确”的话就看看你输入的密码对不对?数据库里的密码是不是加密了?密码这个字段是char类型的字段不?

microcoy 2008-12-04
  • 打赏
  • 举报
回复
还是不对,我干脆把前台页面代码也贴出来。

<form name="password" method="post" action="delhouse.asp"><font color=red>输入密码
<input type="text" name="password">
删除</font>
<input name="Submit" type="submit" value="删除"></form>

同时也感谢sy_binbin的不断纠正和帮助,现在也不能结贴,会给分的,只是问题没有解决!!
sy_binbin 2008-12-04
  • 打赏
  • 举报
回复
rs("SMT_password")=pw
if pw=request("password") then



你这2行啥意思??哎,是马虎还是怎么的??



pw = rs("SMT_password")
if pw=request("password") then
microcoy 2008-12-04
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 sy_binbin 的回复:]

SQL语句是对的
但写完SQL语句你不去执行当然就不正确了
你说呢??


<%
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from SMT_house"
rs.open sql,conn,1,3
rs("SMT_password")=pw
if pw=request("password") then
Sql1="delete from SMT_house where SMT_password='"&Request.Form("password")&"'"
conn.execute…
[/Quote]


非常感谢!可是还是不行,我也就不知道怎么回事了??
sy_binbin 2008-12-04
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 microcoy 的回复:]
1楼的兄弟经验证不正确,谢谢了
[/Quote]


SQL语句是对的
但写完SQL语句你不去执行当然就不正确了
你说呢??


<%
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from SMT_house"
rs.open sql,conn,1,3
rs("SMT_password")=pw
if pw=request("password") then
Sql1="delete from SMT_house where SMT_password='"&Request.Form("password")&"'"
conn.execute(sql1)

rs.close
set rs=nothing
end if
%>
microcoy 2008-12-04
  • 打赏
  • 举报
回复
说的有道理,ID才是主键,应该判断。我把它改成
Sql="delete from SMT_house where SMT_id="&Request.Form(password)
也还是不行??
郁闷!!
microcoy 2008-12-04
  • 打赏
  • 举报
回复
1楼的兄弟经验证不正确,谢谢了
zhuyongzhao 2008-12-04
  • 打赏
  • 举报
回复
你是不是还少了一个判断本条记录的ID号呀,判断本条ID和密码正确的前提下就删除
microcoy 2008-12-04
  • 打赏
  • 举报
回复
Request请求的那条记录呀兄弟!
kid5 2008-12-04
  • 打赏
  • 举报
回复
SMT_password 应该是字符串吧,

语法是
... SMT_password='password'


检查一下你的 SQL语句
sy_binbin 2008-12-04
  • 打赏
  • 举报
回复
要是万一有密码一样的呢??也给删除了吗??

sy_binbin 2008-12-04
  • 打赏
  • 举报
回复
Sql="delete from SMT_house where SMT_password='"&Request.Form("password")&"'"
microcoy 2008-12-04
  • 打赏
  • 举报
回复

"要是万一有密码一样的呢??也给删除了吗?? "

说得没错,终于出现这样的问题了,咋整??

谢谢了!!

28,390

社区成员

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

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