<script language="javascript">
function check()
{
if(document.form2.name2.value=='')
{
window.alert("请输入用户名")
return false
}
if(document.form2.mima2.value=='')
{
window.alert("请输入密码")
return false
}
return true
}
</script>
<table border="0" id="table1" align="center">
<caption>用户登录</caption>
<form name="form2" onsubmit="return check()" method="post" action="">
<tr>
<td><p align="right"><font face="宋体" color="#000000" size="4">用户名</font></p></td>
<td><p align="center"><font color="#000000" size="4"><input type="text" name="name2"></font></p></td>
</tr>
<tr>
<td><p align="right"><font face="宋体" color="#000000" size="4">密码</font></p></td>
<td><p align="center"><font color="#000000" size="4"><input type="password" name="mima2"></font></p></td>
</tr>
<tr>
<td><p align="center"><font face="宋体" color="#000000" size="4">类别</font></p></td>
<td><p><font color="#000000" size="4"><input type="radio" value="老师" checked name="vari1">老师
<input type="radio" value="学生" name="vari1">学生</font></p></td>
</tr>
<tr align="center">
<td colspan="2" bgcolor="#FFFFFF">
<input type="submit" name="button" id="button" value="登陆"/>
</td>
</tr>
</form>
</table>
<%
if isempty(session("passed")) then
session("passed")=false
end if
if request.Form("name2")<>"" and request.Form("mima2")<>"" then
Dim conn,strName,strmima,strleibei
strName=Request.Form("name2")
strmima=Request.Form("mima2")
strleibie=request.form("leibie")
set conn=server.CreateObject("adodb.connection")
conn.open "dsn=massage;uid=sa;pwd=sa"
set rs=server.CreateObject("adodb.recordset")
set rs.activeconnection=conn
rs.cursorType=3
if strleibie="老师" then
strsql="select * from teacher where Tusername='"&strName&"'"
set ws=conn.execute(strsql)
if ws<>strname then
session("err")="用户不存在"
%>
<script language="javascript">
window.alert("该用户没有注册,请点击注册")
</script>
<%
else
if strmima<>rs.fields("Tuserpwd") then
session("err")="密码不正确"
%>
<script language="javascript">
window.alert("密码不对")
</script>
<%
else '登陆成功
err=""
session("passed")=true
session("strName")=rs.fields("Tusername")
session("strmima")=rs.fields("Tuserpwd")
session("err")=""
response.Redirect("注册.asp")
end if
end if
else
rs.open "select * from student where Susername='"&strName&"'"
if rs.eof then
session("err")="用户不存在"