asp修改加入登录判断

来源:百度知道 编辑:UC知道 时间:2024/05/21 18:37:05
怎么在下面的代码内加入一个登录判断啊?
哪位老大指点下啊?
我怎么加都有错误显示。
<%
id=checkstr(request("id"))
szpws=md5(checkstr(request("szpws")))
if id<>"" then
set us=conn.execute("select * from info where password='"&szpws&"' and id="&id)
if not us.eof then
session("user_admin")=0
%>
<%
id=checkstr(request("id"))
szpws=md5(checkstr(request("szpws")))
if id<>"" then
set us=conn.execute("select * from info where 修改密码='"&szpws&"' and 自动编号="&id)
if not us.eof then
session("user_admin")=0
else
response.Write("<script language=vbscript>msgbox""登陆错误:您的密码错误,请重新输入!"",64:history.back()</script>")
end if
%>

if id<>"" then
set us=conn.execute("select * from info where password='"&szpws&"' and id="&id)
if not us.eof then
session("user_admin")=0

如果id不为空的情况下,执行Select * from info where password='XXX' and id= "XXX" 这条语句就是在做登录的验证了!

如果不是记录集的最后一条
session("user_admin") 就赋值为 0
可以加上一个else,来描述是记录集最后一条的情况。

这样你就可以判断session("user_admin")的值来确定是否登录了
if session("user_admin") = 0 then
begin
response.write("登录失败")
'还有什么登录失败后的操作写这里
else
response.write("登录成功")
'还有什么登录成功后的操作写这里
end if

还有你的id 一定是个数字吗?????
如果id是英文或者是引文数字组合的话,这条SQL语句要出错的。。