Re: [問題] 限定時間過後即關閉系統的程式
※ 引述《noguchi (耶?!)》之銘言:
: 現在在做一個網路報名系統
: 但報名總有限定時間
: 比如說到幾月幾日的幾點截止
: 那要怎麼寫呢?
: 或者是我可以到哪個程式板問呢
做到一半遇到問題了= =
"setdate.htm"是有下拉式選單讓管理者選開始及截止的年月日時
"checkdate.php"把上述資料寫入資料庫裡
到這裡是沒有問題
"project.htm"是讓報名者登入帳號的畫面
"checkidpwd.php"是將project.htm表單資料檢查帳密有無輸入或錯誤
再將"checkidpwd.php"導向"checkdate2.php"
從資料庫欄位的檢查 看是否在開放日期及截止日期範圍內
不過登入之後總是會顯示期限已過 = =
不曉得哪裡錯了 以下是checkdate2.php的程式
<?php
//檢查 cookie 中的 passed 變數是否等於 TRUE
$passed = $_COOKIE["passed"];
/* 如果 cookie 中的 passed 變數不等於 TRUE
表示尚未登入網站,將使用者導向首頁 project.htm */
if ($passed != "TRUE")
{ header("location:project.htm");
exit();
}
$link = mysql_connect("localhost", "root", "password");
if (!$link) die("建立資料連接失敗");
$db_selected = mysql_select_db("ball game", $link);
if (!$db_selected) die("開啟資料庫失敗");
$sql = "SELECT * FROM setdate Where startyear = '$startyear' AND
startmonth = '$startmonth' AND startday = '$startday' AND
starthour = '$starthour' AND closingyear = '$closingyear'
AND closingmonth = '$closingmonth' AND closingday = '$closingday'
AND closinghour = '$closinghour'";
$result = mysql_query($sql, $link);
if (!$result) die("執行 SQL 命令失敗");
if (mysql_num_rows($result) != 0)
{ mysql_free_result($result);
$timestamp1 = mktime($starthour,0,0,$startmonth,$startday,$startyear);
$timestamp2 = mktime($closinghour,0,0,$closingmonth,$closingday,$closingyear);
}
mysql_close($link);
if(time()<$timestamp1) exit('尚未開放');
else if(time()>$timestamp2) exit('期限已過');
else {header("Location:index1.php");}
?>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
※ 編輯: noguchi 來自: 203.64.183.208 (08/09 21:11)
推
08/10 00:23, , 1F
08/10 00:23, 1F
→
08/10 00:34, , 2F
08/10 00:34, 2F
→
08/10 00:38, , 3F
08/10 00:38, 3F
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章