0

我已经编写了一个 php 代码来由管理员设置截止日期,因此管理员通过表单输入 daedline 日期并将其存储在数据库中,现在我想使用此截止日期来检查用户何时想要访问页面,如果截止日期到期,用户无法访问此页面,它会自动将他移动到名为“closed.html”的页面,如果不是,用户可以访问它..我已经尝试过这段代码,但它一直让我关闭。 html 页面即使日期还没有过期!请问有什么想法吗?

<?php
session_start();
$Load=$_SESSION['login_user'];
$sql= "Select deadline from schedule_deliverables";
$deadline = mysql_query($sql);
$todays_date = date("Y-m-d");

$today = strtotime($todays_date);
$expiration_date = strtotime($deadline);

if ($expiration_date > $today) {
     echo "<meta http-equiv='refresh' content='1;URL=Check_file.php'>"; //user can access the page 
} else {
     echo "<meta http-equiv='refresh' content='1;URL=closed.html'>"; //deadline is past user can't access 

}


?>
4

1 回答 1

1

你需要 fetch_Array

$query = "Select deadline from schedule_deliverables"; 

$result = mysql_query($query) or die(mysql_error());


$row = mysql_fetch_array($result) or die(mysql_error());
$deadline = $row['deadline']; // and then you rest code with that if
于 2012-12-17T11:42:50.847 回答