ASP 同一个登录窗口进3个不同页面stu.asp、tea.asp、admin.asp 我只能进一个谁帮我看看代码这么写

jxchaohai 2008-12-09 08:29:32
<!-- #include file= "conn.fun" -->
<html>
<head>
<link rel="stylesheet" href="common.css" type="text/css">
<title>信息工程学院毕业论文管理系统</title>
</head><body>
<%
'取得用户名和密码,并删除用户名和密码中的首尾空格
username=trim(request.form("username"))
userpass=trim(request.form("password"))
commandtext="select * from t_user where d_user='"&username&"'"
set rs=conn.execute(commandtext,recordsaffected,adcmdtext)
'检查用户名和密码是否正确
if rs.eof then
response.write "<p>对不起,指定的用户名不存在!</p>"
response.write "<a href='index.asp'>返回首页</a>"
response.end
end if
if userpass=rs("d_pass") then
session("level")=rs("d_level")
response.redirect "stu.asp"
else
response.write "<p>对不起,密码错误!</p>"
response.write "<a href='index.asp' target='_blank'>返回首页</a>"
end if
set conn=nothing
%>
</body></html>
...全文
144 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jxchaohai 2008-12-09
  • 打赏
  • 举报
回复
我把表改了1,2.0表示学生,老师,管理员
还是不行
<!-- #include file= "conn.fun" -->
<html>
<head>
<link rel="stylesheet" href="common.css" type="text/css">
<title>信息工程学院毕业论文管理系统</title>
</head><body>
<%
'取得用户名和密码,并删除用户名和密码中的首尾空格
username=trim(request.form("username"))
userpass=trim(request.form("password"))
commandtext="select * from t_user where d_user='"&username&"'"
set rs=conn.execute(commandtext,recordsaffected,adcmdtext)
'检查用户名和密码是否正确
if rs.eof then
response.write "<p>对不起,指定的用户名不存在!</p>"
response.write "<a href='index.asp'>返回首页</a>"
response.end
end if
[code=vbscript]
if userpass=rs("d_pass") then
session("utype")=rs("utpye")
if rs("utype") = "1" then
response.redirect "stu.asp"
else if rs("utype") = "2" then
response.redirect "tea.asp"
else if rs("utype") = "0" then
response.redirect "admin.asp"
end if
else
response.write " <p>对不起,密码错误! </p>"
response.write " <a href='index.asp' target='_blank'>返回首页 </a>"
end if
[/code]
set conn=nothing
%>
</body></html>
blueterry 2008-12-09
  • 打赏
  • 举报
回复
hehe, 程序哪能照搬呢?

我告诉你的是原理,utype就是你所说的d_level

1,2,0 并不一定在你的程序中就是表示的是学生,老师,管理员。

稍微多思考一下,你就能做出来了。
jxchaohai 2008-12-09
  • 打赏
  • 举报
回复
自己顶下
jxchaohai 2008-12-09
  • 打赏
  • 举报
回复
还是不行啊
<!-- #include file= "conn.fun" -->
<html>
<head>
<link rel="stylesheet" href="common.css" type="text/css">
<title>信息工程学院毕业论文管理系统</title>
</head><body>
<%
'取得用户名和密码,并删除用户名和密码中的首尾空格
username=trim(request.form("username"))
userpass=trim(request.form("password"))
commandtext="select * from t_user where d_user='"&username&"'"
set rs=conn.execute(commandtext,recordsaffected,adcmdtext)
'检查用户名和密码是否正确
if rs.eof then
response.write "<p>对不起,指定的用户名不存在!</p>"
response.write "<a href='index.asp'>返回首页</a>"
response.end
end if
[code=vbscript]
if userpass=rs("d_pass") then
session("level")=rs("d_level")
if rs("utype") = "1" then
response.redirect "stu.asp"
else if rs("utype") = "2" then
response.redirect "tea.asp"
else if rs("utype") = "0" then
response.redirect "admin.asp"
end if
else
response.write " <p>对不起,密码错误! </p>"
response.write " <a href='index.asp' target='_blank'>返回首页 </a>"
end if
[/code]
set conn=nothing
%>
</body></html>
jxchaohai 2008-12-09
  • 打赏
  • 举报
回复
d_level 我表设置为用户类型了 是不是把utype换成d_level
blueterry 2008-12-09
  • 打赏
  • 举报
回复
假设在t_user表中,utype表示的是用户类型,比如1是学生,2是老师, 0是管理员
这样就可以写成
[code=vbscript]
if userpass=rs("d_pass") then
session("level")=rs("d_level")
if rs("utype") = "1" then
response.redirect "stu.asp"
elseif rs("utype") = "2" then
response.redirect "tea.asp"
elseif rs("utype") = "0" then
response.reidrect "adm.asp"
else '未知用户类型,跳转到学生
response.redirect "stu.asp"
end if
else
response.write " <p>对不起,密码错误! </p>"
response.write " <a href='index.asp' target='_blank'>返回首页 </a>"
end if
[/code]

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧