大理石线条拼装造型:asp编程,登陆问题

来源:百度文库 编辑:神马品牌网 时间:2024/04/27 19:25:30
asp编程,登陆问题 ,我的数据库中有两个用户表,如管理员和普通用户,我想在首页登陆框中做单选按钮,用户可以选择管理员或普通用户,然后输入帐号密码进入相关页面,这个登陆页怎么做啊,表单我会,怎样处理选择管理员或普通用户,和数据库中的帐号密码比较呢,我的是2个表
我还想问问jinyu1033,我是个新手,是不是只要在你写的页面中更改 管理员表 用户表 和登陆后页面的名字 就可, 不用做其他任何事,还有我的管理员表有级别的为超级(0)和普通管理(1),普通用户表没有级别,是不是要在页顶加<!--#include file="Connections/conn.asp" --> 数据库连接文件

我在记事本上敲的,原理基本上是这样:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="/">
<table width="100%" height="97" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="47%" height="21"><div align="right">用户名:</div></td>
<td width="53%"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td height="24"><div align="right">密 码:</div></td>
<td><input name="password" type="text" id="password"></td>
</tr>
<tr>
<td height="19"><div align="right">登陆身份:</div></td>
<td>管理员
<input name="loginflag" type="radio" value="1" checked>
普通用户
<input type="radio" name="loginflag" value="0">
<input name="flag" type="hidden" id="flag" value="1"></td>
</tr>
<tr>
<td><div align="right">
<input type="submit" name="Submit" value="提交">
</div></td>
<td><input type="reset" name="Submit2" value="重置"></td>
</tr>
</table>
</form></td>
</tr>
</table>
<%
dim flag
flag=request.form("flag")
if flag<>"1" then
else
dim username,password,loginflag
username=request.form("username")
password=request.form("password")
loginflag=request.form("loginflag")
dim rs,sql
set rs=server.createobject("adodb.recordset")
if loginflag="1" then
sql="select * from 管理员表 where username='"&username&"' and password='"&password&"'"
else
sql="select * from 普通用户表 where username='"&username&"' and password='"&password&"'"
end if
rs.open sql,conn,1,1
if rs.eof or rs.bof then
response.write "<script>alert('用户名或密码错误');javascript:window.history.go(-1);</script>"
rs.close
set rs=nothing
conn.close
set conn=nothing
response.end
else
response.redirect "你要登陆的页面!"
rs.close
set rs=nothing
conn.close
set conn=nothing
end if
end if
%>
</body>
</html>
但是里面还有很多地方要完善,如过滤非法字符等!
如果有什么问题,在问我!
一个表你会,两个表也是一样的!加多一个if判断就行了

你可以设一个变量,选择普通用户时给它赋值为0,以管理员用户时赋给它为1,然后:
比如该变量为strue,你用户表为user,管理员表为admin,则:
if strue = 0 then
table = "user"
else if strue = 1
table = admin
end if
end if
sql = "select password from "&table&" where username = '"&username&"'"