今日头条新闻api接口:asp怎样实现用户登录界面

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 11:17:30
现有一个登录主页index.asp,bangong.asp登录后的页面,数据库文件为psd.mdb,请问怎样实现用户登录界面

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

具体要看数据库的内部结构。
大体做法是:
用index.asp中的表单采集用户名和密码。然后发送到处理页面(可以是本身页面,也可以是其它的处理页面)。

处理页面验证信息,如果用户名密码正确,则跳转到BANGONG.ASP如果错误,返回index.asp页面,并提示错误信息。