<%@LANGUAGE="
VBSCRIPT" CODEPAGE="936"%>
<%
dim uid ,upwd
'获取并简单处理用户输入的信息
uid=trim(Request.Form("txt_id"))
upwd=trim(Request.Form("txt_pwd"))
ushf=request("shf")
'判断用户是否登录,否则提示登录
if uid="" or upwd="" then
response.write ""
response.end
end if
'定义一个记录集对象rs
set rs=server.createobject("adodb.recordset")
'根据登录身份设置不同的SQL字符串和身份标志变量,并引导到不同页面
if ushf="admin" then
geturl="admin.asp"
flag="admin"
sqltext="select * from admin where admin_name='" &; uid &; "' and admin_pwd='" &; upwd
&; "'"
else if ushf="user" then
geturl="user.asp"
flag="user"
sqltext="select tc_id from infor where tc_name='" &; uid &; "' and tc_pwd='" &; upwd &; "'"
end if
else if ushf="pwd" then
geturl="user.asp"
flag="user"
sqltext="select in_id from infon where in_name='" &; uid &; "' and in_pwd='" &; upwd &; "'"
end if
end if
'利用上面定义的SQL字符串打开记录集
rs.open sqltext,conn,1,1
'判断记录集是否存在记录
if rs.recordcount >= 1 then
'根据不同身份,定义uid变量的值,该值为表中的主键字段
if ushf="user" then
uid = rs("tc_id")
elseif ushf="admin" then
uid = rs("admin_id")
elseif ushf="pwd" then
uid = rs("in_id")
End if
'定义cookie对象分别保存用户输入的信息
response.cookies("flag") = flag
response.cookies("uid") = uid
response.cookies("upwd") = upwd
'跳转到相应的页面
Response.Redirect geturl
'关闭该记录集
rs.close
else
'当用户名和密码不对时,给出提示信息,并返回首页要求重新登录
response.write ""
response.end
rs.close
end if
%>
<% dim type1 '获取并简单处理用户输入的信息 type1=request("type") username=request("username") password=request("password") if type1="1" then '定义一个记录集对象rs set rs=server.createobject("adodb.recordset") sql="select * from student where mm='"&;pass
word&;"' and xh='"&;username&;"'"
rs.open
sql,conn,3,1
'根据登录身份设置不同的SQL字符串和身份标志变量,并引导到不同页面
if rs.recordcount<=0 then response.redirect "login.asp" else session("type")=type1 response.redirect "mainframe.asp" end if elseif type1="2" then set rs=server.createobject("adodb.recordset") sql="select * from qyxx where mm='"&;password&;"' and qyxh='"&;username&;"'" rs.open sql,conn,3,1 if rs.recordcount<=0 then response.redirect "login.asp" else session("type")=type1 response.redirect "mainframe.asp" end if else set rs=server.createobject("adodb.recordset") sql="select * from admin where adminmm='"&;password&;"' and adminid='"&;username&;"'" rs.open sql,conn,3,1 if rs.recordcount<=0 then response.redirect "login.asp" else session("type")=type1 response.redirect "mainframe.asp"
end if
end if
%>