【发布时间】:2014-04-26 18:41:19
【问题描述】:
$test = $info['date'] . $info['time'];
$date = date("Y-m-d H:i:s", strtotime($test));
if (isset($_SESSION['id']) && $_SESSION['id'] == $_GET['id'])
{
if (isset($_GET['BookID']) && is_numeric($_GET['BookID']))
{
if ($date >= (time() + 86400)) {
// current time is 86400 (seconds in 24 hours) or less than stored time
$sql = "DELETE FROM `tbl_booking` WHERE `BookID`={$BookID}";
$result = mysqli_query($con, $sql);
//header("refresh:5;url=dashboard.php");
echo "Your booking has been cancelled.";
}
}
} else {
// if id isn't set, or isn't valid, redirect back to view page
//header("refresh:5;url=dashboard.php");
echo ("Sorry, there is less than 24 hours left and you cannot cancel.");
}
对不起,我到处找了这个,我仍然无法理解。
基本上,我正在制作一个允许用户取消但如果他们尝试预订的时间少于 24 小时的预订系统。
目前这似乎拒绝每一个删除,说即使没有还剩不到 24 小时。
【问题讨论】:
-
我已经在那里问过了,但是当我解决了这个问题时,我的问题已经改变了。问题是没有人真正回复那里了。
-
您将日期字符串与 unix 时间戳进行比较,您还需要将 $date 转换为 unix 时间戳。
-
好的,我会调查的,谢谢
-
$info['date']和$info['time']是否来自数据库?如果是这样,有更简单的方法可以在 SQL 查询中按照您想要的方式获取它。 发布您的查询以获得预订! -
至少在示例中您没有定义 $BookID。