为什么我设计的网页登录不了
我在设计网页登录界面输入的用户和密码都是正确的时老是执行:登陆失败!\n\n错误原因:帐号和密码未填。哪位高手救救我啊!帮看看错在哪里
conn.asp 代码:
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("contacts.mdb")
%>
login.asp代码:
<form name="login" method="post" action="after_login.asp">
用户名:<input name="Unam" size="12" maxlength="16">密 码:<input name="pwd" size="12" type="password" maxlength="16">
<input align="absMiddle" id="image1" name="image1" src="images/login.gif" type="image" WIDTH="37" HEIGHT="20">
</form>
after_login.asp代码:
<!--#include file="conn.asp"-->
<%
Dim Unam,pwd
Unam=Trim(Request.Form("Unam"))
pwd=Trim(Request.Form("pwd"))
If Unam="" or pwd="" Then
Response.Write ("<script>alert('登陆失败!\n\n错误原因:帐号和密码未填。');history.back();</script>")
Response.end
End If
if Instr(Unam,">")>0 or Instr(Unam,"<")>0 or Instr(Unam,"=")>0 or Instr(Unam,"%")>0 or Instr(Unam,chr(32))>0 or Instr(Unam,"?")>0 or Instr(Unam,"&")>0 or Instr(Unam,";")>0 or Instr(Unam,",")>0 or Instr(Unam,"'")>0 or Instr(Unam,chr(34))>0 or Instr(Unam,chr(9))>0 or Instr(Unam,"")>0 or Instr(Unam,"$")>0 then
Response.Write ("<script>alert('登陆失败!\n\n错误原因:含有非法字符!');history.back();</script>")
Response.end
else
Unam=Trim(Unam)
end if
set rs=server.createobject("adodb.recordset")
sql="select * from contacts where Unam='"&Unam&"'"
rs.open sql,conn,1,3
if rs.eof then
Response.Write ("<script>alert('登陆失败!\n\n错误原因:帐号错误。');history.back();</script>")
Response.end
else
if rs("pwd")<>pwd then
rs.close
set rs=nothing
Response.Write ("<script>alert('登陆失败!\n\n错误原因:密码错误。');history.back();</script>")
Response.end
else
session("Unam")=Unam'登录成功传递一个session值以便以后调用用户相关
session.timeout=300
Response.redirect"main.asp"
end if
end if
rs.close
set rs=nothing
CloseDatabase
%>