2014-01-31 73 views
-1

我想設置預訂系統的時間限制。這樣用戶必須 必須刪除其預訂的能力,但在此之前,當預訂已經進入了1分鐘也可遠離時間的推移設置時間刪除預訂php

<?php 
require_once 'connection.php'; 


if(isset($_SESSION['book'])){ 

if (isset($_SESSION['book_time'])){ 
    if (time()-$_SESSION['book_time']>= 60){ 

     if (isset($_POST['delete'])){  

$machineID = $_POST['machine_id']; 
$starttime = $_POST['start_time']; 

$qry = "DELETE FROM bookings where machine_id = '$machineID' AND 
start_time = '$starttime'"; 

$result = mysql_query($qry,$conn); 
if ($result){ 

    if(mysql_affected_rows()>0){ 
     $message[] = 'Booking Deleted form DB'; 
    } 
    } 

    } 
} 
} 
    } 
?> 

,但它不能與此即使刪除後1分鐘腳本....這可能是可能出現的問題

+0

你問同樣的問題... – user1844933

+0

好,什麼是$開始時間之前? – user1844933

+0

你在$ _session ['book_time']中獲得了什麼? – alwaysLearn

回答

0

變化

if (isset($_POST['delete'])){  

$machineID = $_POST['machine_id']; 
$starttime = $_POST['start_time']; 

if (isset($_POST['delete']) && (time()-$_SESSION['book_time']>= 60)){  

$machineID = $_POST['machine_id']; 
$starttime = $_POST['start_time']; 
0

試試這個...

iF ((int)$starttime+60 > time()) { 
$qry = "DELETE FROM bookings where machine_id = '$machineID' AND start_time = '$starttime'"; 
}