<%@ language=javascript %>
<%
var username,userpwd,msg;
if (!Session("PASSED"))
Session("PASSED")=false;
if (Session("PASSED")==false)
{
username = Request.Form("UserName");
userpwd = Request.Form("UserPwd");
if (username == "" ) /* 用了null也不行,还是进入else */
{
msg = "请输入帐号密码"
}
else
{
var Conn = Server.CreateObject("ADODB.Connection");
Conn.ConnectionString="driver={SQL Server};server=AHU-RU034EIDTZJ;UID=sa;PWD=sa;Database=testsql";
Conn.Open();
var rs = Server.CreateObject("ADODB.Recordset");
rs.ActiveConnection = Conn;
rs.CursorType = 3;
rs.Open("select * from usermap where username=username"); /* 我变量和数据库表都是用username */
if (rs.EOF) /* 怎么区别啊?不能用this.username */
{ /* 我把所有username改成usernames后*/
msg = "用户不存在"; /* [Microsoft][ODBC SQL Server Driver][SQL Server]列名 'usernames' 无效 */
}
else
{
if (userpwd != rs.Fields("userpwd"))
{
msg = "密码不正确";
}
else
{
msg = "欢迎光临";
Session("PASSED")=true;
Session("USERNAME")=rs.Fields("username");
Session("USERID")= rs.Fields("userid");
}
}
}
}
%>
<html>
<body>
<%= msg %>
<form action="index.asp" method=post >
<input type="text" name="UserName" />
<input type=password name="PassPwd" />
<input type="submit" value="确定" />
<a href="1.asp">1.asp</a>
</form>
</body>
</html>