案例:如何?網上考試?

來源:互聯網
上載者:User
下面就是滿足你設想的幾個主程式,你還可以在實際應用中不斷完善和擴充:

login.asp
' 考生驗證
<%@ Language=VBScript%>
<%
name=trim(request("name"))
passwd=trim(request("passwd"))
if name<>"" and passwd<>"" then
' 檢查考生是否輸入使用者名稱和密碼
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver(*.mdb)};
dbq="& Server.MapPat("exercise.mdb")
set rs= server.createobject("adodb.recordset")
sql= "select * from user where user=
'" &name&"' and passwd='" & passwd &"'"
Set rs= conn.Execute(sql)
' 驗證考生合法性
if not(rs.eof) then
if rs("score")<>0 then
' 檢查考生是否已參加過考試,若是則進行成績查詢
response.write rs("user")&"的考試成績是"&rs("score")
else
session("pass")=1
session("user")=name
response.redirect "test.asp"
end if
else
Response.Write "噢,您輸入的使用者名稱或密碼不正確!"
end if
else
end if
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>精彩春風之考生登入</TITLE>
</HEAD>
<BODY>
<FORM action="login.asp" id=
FORM1 method=post name=FORM1>
<P title="">&nbsp;</P>
<P title="">&nbsp;</P>
<P title="" align=center>考生:
<INPUT id=text1 name=name style="HEIGHT:22px; WIDTH: 103px"></P>
<P title="" align=center>密碼:
<INPUT id=password1 name=passwd style="HEIGHT: 23px; WIDTH: 101px" type=password></P>
<P title="" align=center>
<INPUT id=submit1 name=submit1 type=submit value="進入 " style="FONT-SIZE: medium; FONT-STYLE: normal; FONT-VARIANT:normal; FONT-WEIGHT: bold" title=""></P>
<P title="" align=center>
</P>
</FORM>
</BODY>
</HTML>

test.asp
' 從題庫中取題考試
<%@ Language=VBScript %>
<%
if session("pass")<>1 then
response.redirect "login.asp"
else
end if
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};
dbq="& Server.MapPath("exercise.mdb")
sql="select * from test"
Set rs = conn.Execute( sql )
' 提取試題
%>

<SCRIPT LANGUAGE="JavaScript">
var isn1=null;
var isn2=false;
today=new Date();
function stopit(){
if(isn2){
clearTimeout(isn1);
}
isn2 = false;
}
function startit(){
stopit();
isnclock();
}
function isnclock(){
var now=new Date();
var hrs=now.getHours();
var min=now.getMinutes();
var sec=now.getSeconds();
document.clckh.disp.value=""+((hrs>12) ? hrs-12 : hrs);
document.clckm.disp.value=((min<10) ? "0" : "")+min;
document.clcks.disp.value=((sec<10) ? "0" : "")+sec;
document.clck.disp.value=(hrs>=12) ? "p.m." : "a.m.";
isn1=setTimeout("isnclock()",1000);
isn2=true;
}
</SCRIPT>
' 以上是一個計時函數

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY onLoad="startit()" BGCOLOR="FFFFFF">
<center>
' 調用計時函數顯示時間
<TABLE BORDER=2>
<TR>
<TD>Time</TD><TD>Hour</TD><TD>Min</TD><TD>Sec</TD><TD></TD>
</TR>
<TR>
<TD></TD>
<TD VALIGN=TOP><FORM NAME="clckh" onSubmit="0">
<INPUT TYPE="text" NAME="disp" SIZE=2 VALUE ="">
</FORM></TD>
<TD VALIGN=TOP><FORM NAME="clckm" onSubmit="0">
<INPUT TYPE="text" NAME="disp" SIZE=2 VALUE ="">
</FORM></TD>
<TD VALIGN=TOP><FORM NAME="clcks" onSubmit="0">
<INPUT TYPE="text" NAME="disp" SIZE=2 VALUE ="">
</FORM></TD>
<TD VALIGN=TOP><FORM NAME="clck" onSubmit="0">



相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。