robera
robera

Reputation: 11

Setting time limit php

I am trying to set time limit in reservation system. Such that Users must have the ability to remove their bookings, but not before the lapse of 1 minute away from the time when the booking has been entered

 <?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';
    }
  }

    }
}
 }
  }
?>

but it couldn't remove even after 1 min with this script....what could be possible problem

Upvotes: 0

Views: 358

Answers (1)

MustDie1Bit
MustDie1Bit

Reputation: 561

Possible problems:

  • $_SESSION['book'] or $_SESSION['book_time'] or $_POST['delete'] is NULL
  • $machineID contains not exists ID
  • $starttime contains wrong time or time in wrong format

Try to dump this variables. If they are ok try to run query manualy.

Upvotes: 1

Related Questions