[求助]这段用户登陆的代码怎么不行?
conn.asp
dim conn
set conn=Server.createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath("lanier_db.mdb")
If err.number<>0 then
Response.write("连接数据库时产生错误!")
Response.End
End if
%>
login.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form method="post" action="check.asp">
用户名:<input type="text" name="userid" size="20">
密 码: <input type="text" name="pwd" size="20">
<input type="submit" name="submit1" value="登录">
<input type="reset" name="button1" value="清除">
</form>
</body>
</html>
check.asp
<%
Dim Rs,Sql,Userid,Pwd
Userid=Request.form("Userid") '提取login.asp页面的用户名;
Pwd=Request.form("pwd") '提取login.asp页面的密码;
Set Rs=Server.Createobject("adodb.recordset")
Sql="select * from login where userid='"&Userid&"' "
Rs.open sql,conn,1,1
If rs.eof and rs.eof then '判断用户名是否存在
Response.write "<script language=javascript>alert('用户不存在');history.go(-1);</script>"
Response.End
Elseif Rs("pwd")<>pwd then '判断密码是否正确
Response.write "<script language=javascript>alert('密码错误');history.go(-1);</script>"
Response.End
Else
Session("userid")=userid '把用户名写入session
Response.redirect("index.asp")
End if
%>
麻烦各位给看一下,急用!
[此贴子已经被作者于2007-6-15 9:46:24编辑过]