越狱第一季第九集台词:ASP+代码的用户登录

来源:百度文库 编辑:高考问答 时间:2024/04/23 23:50:14

<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>

<table>
<tr><form method="POST" action="">
<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><input type="submit" value="登录" name="submit"></td>
</tr></form>
</table>
<%
if request("submit")="登录" then
user=request.form("user") '得到user的值
pass=request.form("pass") '得到pass的值

'_____________以下是连接数据库_________________________
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 users where username='"& user &"'" and password='"& pass &"'" '检查用户名和密码
rs.open sql,conn,1,1
if rs.eof then
response.write "没有该用户"
else
session("username")=rs("username")
response.write "登陆成功!"
end if '结束查询
end if '结束登陆

%>