设定时间限制php [英] Setting time limit php

查看:76
本文介绍了设定时间限制php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在预订系统中设置时间限制.这样用户必须 可以删除其预订,但不能在输入预订后1分钟之内取消

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

    }
}
 }
  }
?>

但是使用此脚本1分钟后仍无法删除....可能是什么问题

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

推荐答案

可能的问题:

  • $ _ SESSION ['book']或$ _SESSION ['book_time']或$ _POST ['delete']为NULL
  • $ machineID包含不存在的ID
  • $ starttime包含错误的时间或格式错误的时间

尝试转储此变量.如果可以,请尝试手动运行查询.

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

这篇关于设定时间限制php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆