asp怎样实现用户登录界面 20
现有一个登录主页index.asp,bangong.asp登录后的页面,数据库文件为psd.mdb,请问怎样实现用户登录界面...
现有一个登录主页index.asp,bangong.asp登录后的页面,数据库文件为psd.mdb,请问怎样实现用户登录界面
展开
2个回答
展开全部
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户登录</title>
</head>
<body>
<%
if request("cmd")="login" then
user=request.form("user")
pass=request.form("pass")
Dim Conn
Dim Rs
Dim DbPath
Set Conn=Server.CreateObject("ADODB.Connection")
Set Rs=Server.CreateObject("ADODB.Recordset")
DbPath=Server.Mappath("数据库路径")
Conn.Open ("Provider=Microsoft.OLEDB.JET.4.0;Data Source="& DbPath)
sql="select * from [表名] where [用户字段]='"& user &"'" and [密码字段]='"& pass &"'"
rs.open sql,conn,1,1
if rs.eof then
response.write ("<script language=""javascript"">alert(""没有该用户"");location.href(""index.asp"")</script>")
response.end
else
response.write ("<script language=""javascript"">alert(""登录成功"");location.href(""bangong.asp"")</script>")
end if
end if
%>
<form method="POST" action="index.asp?cmd=login">
<div align="center">
<table border="0" width="400" cellspacing="0" cellpadding="0" id="table1">
<tr>
<td align="right">用户:</td>
<td><input type="text" name="user" size="20"></td>
</tr>
<tr>
<td align="right">密码:</td>
<td><input type="password" name="pass" size="20"></td>
</tr>
<tr>
<td align="right"> </td>
<td><input type="submit" value="登录" name="B1"></td>
</tr>
</table>
</div>
</form>
</body>
</html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户登录</title>
</head>
<body>
<%
if request("cmd")="login" then
user=request.form("user")
pass=request.form("pass")
Dim Conn
Dim Rs
Dim DbPath
Set Conn=Server.CreateObject("ADODB.Connection")
Set Rs=Server.CreateObject("ADODB.Recordset")
DbPath=Server.Mappath("数据库路径")
Conn.Open ("Provider=Microsoft.OLEDB.JET.4.0;Data Source="& DbPath)
sql="select * from [表名] where [用户字段]='"& user &"'" and [密码字段]='"& pass &"'"
rs.open sql,conn,1,1
if rs.eof then
response.write ("<script language=""javascript"">alert(""没有该用户"");location.href(""index.asp"")</script>")
response.end
else
response.write ("<script language=""javascript"">alert(""登录成功"");location.href(""bangong.asp"")</script>")
end if
end if
%>
<form method="POST" action="index.asp?cmd=login">
<div align="center">
<table border="0" width="400" cellspacing="0" cellpadding="0" id="table1">
<tr>
<td align="right">用户:</td>
<td><input type="text" name="user" size="20"></td>
</tr>
<tr>
<td align="right">密码:</td>
<td><input type="password" name="pass" size="20"></td>
</tr>
<tr>
<td align="right"> </td>
<td><input type="submit" value="登录" name="B1"></td>
</tr>
</table>
</div>
</form>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询