【求助】線上考試程式∼∼急 - PCZONE 討論區

返回   PCZONE 討論區 > ▲ -- 電 腦 軟 體 討 論 區 > -- 網 路 軟 體 討 論 二 版 (網路其他軟體)


PCZONE 討論區



通知

-- 網 路 軟 體 討 論 二 版 (網路其他軟體) 包括檔案傳輸和下載、網頁搜尋、網路工具、聊天、多媒體、架站軟體、線上字典等的疑難解答。

會員
【求助】線上考試程式∼∼急
我正在製作一個考試的程式,每個人考試次數限制為五次,其中資料庫用SQL,裡頭有一個欄位名為

LOG_TIMES(在USER資料表中),登入頁面中有一個表單,我把動作設為LOGIN.ASP,我想在登入的時候資料

庫中的LOG_TIMES會自動加1,當LOG_TIMES大於五的時候就不允許登入。

使用者共有10個人,每個人的考試次數皆為五次,登入的時候登入ID的LOG_times會自己加1,這個程式要怎麼寫呢?小弟一直都用DW設計,導致基礎不是很好!請各位高手幫幫忙吧!
以下為login.asp的原始碼:
--------------------------------------------------------------------------------------------
<!-- #include file="odbc.asp" -->

<%

'purpose:login
'

set conn=server.createobject("adodb.connection")
set rs = server.createobject("adodb.recordset")

conn.open connection_setting

sql = "select * from users where id = '"& request("Id") &"'"
set rs = conn.execute(sql)

session("answertime") = 120 '設定考試的時間
session("examtimes") = 5 ' 設定一科能考的次數

if (rs.bof and rs.eof) then
response.write "此帳號不存在!"
response.end
else
if rs("pwd") <> request("pwd") then
response.write "您的密碼錯誤!"
response.end
else
session("id") = rs("ID")
session("role") = rs("role")
response.redirect "exam_select.asp"
end if
end if
%>
--------------------------------------------------------------------------------------------

回覆
進階會員

紀錄次數的欄位是USER資料表的LOG_TIMES欄位嗎?
---------------------------------------------------------------------------------------
<!-- #include file="odbc.asp" -->

<%

'purpose:login
'

set conn=server.createobject("adodb.connection")
set rs = server.createobject("adodb.recordset")

conn.open connection_setting

sql = "select * from users where id = '"& request("Id") &"'"
set rs = conn.execute(sql)

session("answertime") = 120 '設定考試的時間
session("examtimes") = 5 ' 設定一科能考的次數

if (rs.bof and rs.eof) then
response.write "此帳號不存在!"
response.end
else
if rs("pwd") <> request("pwd") then
response.write "您的密碼錯誤!"
response.end
else
if rs("LOG_TIMES") > 5 then
Response.write "您的考試次數超過5次"
Response.End

else
session("id") = rs("ID")
session("role") = rs("role")
response.redirect "exam_select.asp"
end if
end if
end if
%>
------------------------------------------------------------------------------------
回覆
會員

引用:
最初由 jessee780522 發表
紀錄次數的欄位是USER資料表的LOG_TIMES欄位嗎?
---------------------------------------------------------------------------------------
<!-- #include file="odbc.asp" -->

<%

'purpose:login
'

set conn=server.createobject("adodb.connection")
set rs = server.createobject("adodb.recordset")

conn.open connection_setting

sql = "select * from users where id = '"& request("Id") &"'"
set rs = conn.execute(sql)

session("answertime") = 120 '設定考試的時間
session("examtimes") = 5 ' 設定一科能考的次數

if (rs.bof and rs.eof) then
response.write "此帳號不存在!"
response.end
else
if rs("pwd") <> request("pwd") then
response.write "您的密碼錯誤!"
response.end
else
if rs("LOG_TIMES") > 5 then
Response.write "您的考試次數超過5次"
Response.End

else
session("id") = rs("ID")
session("role") = rs("role")
response.redirect "exam_select.asp"
end if
end if
end if
%>
------------------------------------------------------------------------------------
問題已經解決了∼∼感謝你的回應∼!

回覆







 XML   RSS 2.0   RSS 
本站使用 vBulletin 合法版權程式
站務信箱 : [email protected]

本論壇所有文章僅代表留言者個人意見,並不代表本站之立場,討論區以「即時留言」方式運作,故無法完全監察所有即時留言,若您發現文章可能有異議,請 email :[email protected] 處理。