-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdo_book.php
39 lines (36 loc) · 1.21 KB
/
do_book.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
session_start();
if ($_SESSION['login'] != true) {
header("Location:index.php");
}
$liftime = 5 * 60;
setcookie(session_name(), session_id(), time() + $liftime, "/");
$user = $_POST['user'];
$other = $_POST['other'];
$id = substr($_POST['id'],4);
$date = date("Y-m-d", strtotime($_POST['date']));
$info = explode("&", $other);
$from = $info[0];
$to = $info[2];
$departureTime = $date . " " . $info[1];
$arrivalTime = $date . " " . $info[3];
$duration = $info[4];
include_once "Base.php";
Base::DB_Connect();
$sql = "select * from BookRecord where username='" . $user . "'";
$result = mysql_query($sql);
while ($data = mysql_fetch_array($result)) {
if ((strtotime($data['DepartureTime']) <= strtotime($departureTime)) && (strtotime($departureTime) <= strtotime($data['ArrivalTime']))) {
echo "false";
return;
}
if ((strtotime($data['DepartureTime']) <= strtotime($arrivalTime)) && (strtotime($arrivalTime) <= strtotime($data['ArrivalTime']))) {
echo "false";
return;
}
}
$sql = "INSERT INTO `BookRecord` VALUES (null,'$user','$from','$to','$departureTime','$arrivalTime','$duration','$id')";
mysql_query($sql);
echo "true";
return;
?>