急! 下面是ASP 登陆页面的一段代码 但是不晓得怎么加上session属性 高手帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/09 19:21:30
session加在哪最好 怎么加? 也可以有其它的建设性意见
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from zhucebiao where username='"&username&"' and password='"&password&"'",cn,1,3
if rs.eof then
response.write "<script language=jscript>alert('对不起,您输入的用户名、密码或验证码有误,请重新输入,谢谢!');window.location.href='index.asp';</script>"
else
response.write "<script language=jscript>alert('登录成功!!');window.location.href='kehuliuyan.asp';</script>"
end if
end if
end if
%>
你说的地方 我加了 不能验证密码和用户了 所有的都能成功提交
没加时没有这个问题哦
有个不情之请 解答问题的时候希望你们能测试一下 谢谢了 (本来不好意思说出来的,但真的很急)

<%set rs=server.createobject("adodb.recordset")
rs.open "select * from zhucebiao where username='"&username&"' and password='"&password&"'",cn,1,3
if rs.eof then
response.write "<script language=jscript>alert('对不起,您输入的用户名、密码或验证码有误,请重新输入,谢谢!');window.location.href='index.asp';</script>"
else
session("username")=rs("username") '就加在这里.
response.write "<script language=jscript>alert('登录成功!!');window.location.href='kehuliuyan.asp';</script>"
end if
end if
end if
%>

我觉得你那个alert登陆成功纯属多余.还有,你用的是脚本,如果对方关闭了浏览器脚本,那么你这个限制就多余了.意思就是,你这段代码基本算是废了.在服务器端验证的时候最好不要输出脚本.应该用response.redirect "kehuliuyan.asp"

我把你的代码改了,你看一下
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from zhucebiao where username='"