So I have a form that enters a aircraft reservation into the database…
[php]
" name="aircraft" readonly>
Pilot in Command:
Date:
" name="dt" readonly>
Start Time:
End Time:
[/php]
and when you submit it it passes the info to the next file…
[php]
<?php include('connect.php'); $name = mysqli_real_escape_string($con, $_POST['aircraft']); $user = mysqli_real_escape_string($con, $_POST['user']); $dt = mysqli_real_escape_string($con, $_POST['dt']); $tm = mysqli_real_escape_string($con, $_POST['tm']); $et = mysqli_real_escape_string($con, $_POST['et']); $TM = date('H:i:s', strtotime($tm)); $ET = date('H:i:s', strtotime($et)); if ($result = $con->query("SELECT * FROM cal WHERE ( '$TM' BETWEEN cal_time AND cal_end) OR ('$ET' BETWEEN cal_time AND cal_end) OR (cal_time < '$TM' AND cal_end > '$ET') AND cal_date = '$dt' AND cal_air = '$name'")) { if ($result->num_rows > 0) { header("location:add-sched-error.php"); } } $sql = "INSERT INTO cal (cal_air, cal_user, cal_date, cal_time, cal_end) VALUES('$name', '$user', '$dt', '$tm', '$et')"; if (!mysqli_query($con, $sql)) { die('Error: '.mysqli_error($con)); } header("location:aircraft-schedule.php"); mysqli_close($con); ?>[/php]
but for whatever reason its not catching any overlapping times at all. I have tried multiple examples/ways with no success. I am wondering if its not liking how th form passing dates or times but if so Im not really sure how to fix that either.
the database is using a Date, and Time fields to store the data.
What am I missing?