check_admin.asp

来自「本人的课程设计。不足之处请大家指教。因为第一次用ASP有很多不足的地方。」· ASP 代码 · 共 42 行

ASP
42
字号
<!-- #include file="conn/conn.asp" -->
<%
set rs=server.createobject("adodb.recordset")
sql="select * from student where id='"&trim(request.form("id"))&"'"
rs.open sql,conn,1,1
if not rs.eof then			'取到记录
	if trim(rs("pwd"))=trim(request.form("pwd")) then		'密码正确
	
		 if trim(rs("lev"))=1 then      '考生
		    response.cookies("username")=trim(request.form("id"))
		    response.redirect "student.asp"
		 end if
		 if trim(rs("lev"))=2 then      '老师
			 response.cookies("username")=trim(request.form("id"))
			 response.redirect "button_t.asp"
		 end if
		 if trim(rs("lev"))=3 then      '管理员
			 response.cookies("username")=trim(request.form("id"))
			 response.redirect "button_t.asp"
		 end if
	else
	%>
	<script>
	window.alert("密码错误!")
	history.go(-1);
	</script>
	<%
	end if
else
%>
<script>
window.alert("不存在该账号!")
history.go(-1);
</script>
<%
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?