用ASP開發一個線上考試程式(四)

來源:互聯網
上載者:User
程式|線上 2000-09-08· 編譯青苹果電腦工作室·yesky

Checkuser.asp
  在應用程式的開始,訪問者鍵入了他們的口令之後,他們的細節被指向了一頁,如sendregister.asp,來檢驗一下具體
的使用者名稱和口令在資料庫中是否存在。
sql_check = "select count(*) from loginuser where username ='" & _
username &"' and password = '" & useremail &"'"
Set RS_check = Application("Conn").Execute(sql_check)
If RS_check(0) < > 0 Then
Session("username") = request.form("username")
response.redirect "default.asp"
End If
If RS_check(0) = 0 Then
Session("error") = "WRONG USER NAME OR PASSWORD"
response.redirect "index.asp"
End If
  sql命令檢查一個特定的使用者是否已經註冊了。如果傳回值為0,就表明使用者名稱或email 無效,將使用者引導回註冊頁。
如果是會員,就被引導到default.asp 頁。這一次又用到了替換函數,以保證如果會員鍵入了‘ (單引號),就要用''
(雙引號)來替換。
username = replace(request.form("username"),"'","''")
useremail = replace(request.form("password"),"'","''")
選擇一個測驗
Default.asp
  一旦成功登入,就出現第二個介面,提供會員可以選擇的測驗科目的列表。在本例中,我們有HTML 和DHTML ,當然可
以增加表格以提高主題數。Default.asp 要求表格安裝一個下拉式功能表,其中包含主題的列表。查詢資料庫,從試卷的表格
中搜集兩個域。
sql_papers = "select *id, topic from paper sort order by topic asc"
SET RS_papers = Application("Conn").Execute(sql_papers)
  為了在下拉式功能表中顯示結果,使用以下代碼:
SELECT size=1 name=select1 onchange="msec(document.form1._
select1.options[document.form1.select1.selectedIndex].value);" >
< option value="0" >Select the examination
< %Do while not RS_papers.EOF% >
< option value="< %=RS_papers("id")% >" >< %=lcase(RS_papers("topic"))% >< /OPTION >
< %
RS_papers.MoveNext
Loop
% >
  msec函數在X值的基礎上調用 redirect.asp,把查詢字串: ?x 的值作為下拉式功能表中被選擇的項的值。
function msec(x)
{if (x==0)
{ alert("Please select any one of the Examinations")
}
else
{ location.href="redirect.asp?section=" + x
}
}



聯繫我們

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

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

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.