网络考场(1)(转)logon.asp

来源:岁月联盟 编辑:zhuzhu 时间:2003-07-11
<%@ Language=VBScript %>
<%
if Request.ServerVariables("http_method")="POST" then
    if Request.Form("submit")="进入1" then
        '学生进入网络考场的处理
        set conn=server.CreateObject("adodb.connection")
        conn.ConnectionString="dsn=testsys"
        '连接并打开数据库
        conn.open
        strsql="select * from studentinfo where stid='" & Request.Form("stid") & "' and stname='" & Request.Form("stname") & "'"
        set mrs=conn.Execute(strsql)
        if not mrs.bof and  not mrs.eof then
        '如果数据库中存在该学生的记录进入网络考场
        '并用session属性存储学生的姓名与学号
            session("stid")=Request.Form("stid")
            session("stname")=Request.Form("stname")
            Response.Redirect "stselectsub.asp"
            set mrs=nothing
        else
        '如果数据库中不存在该学生的信息,显示的页面仍为logon.asp,并提示信息
            Response.Write "学生姓名与学号输入错误!!"
        end if
        conn.Close
        set conn=nothing
    else
        '教师进入网络考场的处理
        set conn=server.CreateObject("adodb.connection")
        conn.ConnectionString="dsn=testsys"
        conn.open
        strsql="select * from teacherinfo where teachid='" & Request.Form("teachid") & "' and teachname='" & Request.Form("teachname") & "'"
        set mrs=conn.Execute(strsql)
        if not mrs.bof and not mrs.eof then
        '如果数据库中存在该教师的记录进入网络考场
        '用session属性保持教师姓名与编号
            session("teachid")=Request.Form("teachid")
            session("teachname")=Request.Form("teachname")
            Response.Redirect "tcreatefrm2.asp"
        else
        '如果数据库中不存在该教师的信息,显示的页面仍为logon.asp,并提示信息
            Response.Write "教师的姓名和编号输入错误!!"
        end if
        set mrs=nothing
        '关闭数据库连接
        conn.close
        '清空对象变量
        set conn=nothing
    end if
end if
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<FORM action="logon.asp" method=post id=form1 name=form1>
<P align=center>
<FONT color=crimson face=隶书 size=6>网 络 考 场</FONT></P>
<P align=center>
<TABLE border=0 cellPadding=1 cellSpacing=1 width=75%>
    <TR bgcolor=wheat>
        <TD>
            <DIV align=center><STRONG><FONT
            color=mediumslateblue face=幼圆 size=4>学 生</FONT></STRONG></DIV>
        <TD>
            <DIV align=center><FONT color=mediumslateblue
            face=幼圆 size=4><STRONG>教
            师</STRONG></FONT></DIV>
    <TR  bgcolor=ivory>
        <TD>
        <P align=center>姓名<INPUT id=text1 name=stname></P></TD>
        <TD>
        <P align=center>姓名<INPUT id=text2 name=teachname value=zhong></P></TD></TR>
    <TR  bgcolor=ivory>
        <TD>
        <P align=center>学号<INPUT id=password1 name=stid type=password></P></TD>
        <TD>
        <P align=center>编号<INPUT id=password1 name=teachid type=password ></P></TD></TR>
    <TR  bgcolor=ghostwhite>
        <TD >
            <DIV align=center><INPUT id=submit1 name=submit type=submit value=进入1 ></DIV></TD>
        <TD>
            <DIV align=center><INPUT id=submit2 name=submit type=submit value=进入2></DIV></TD></TR></TABLE></P>
</FORM>
</BODY>
</HTML>