-
Notifications
You must be signed in to change notification settings - Fork 0
/
reserve.php
35 lines (28 loc) · 983 Bytes
/
reserve.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
<?php
session_start();
include 'templates/db-con.php';
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$rest_id = $_GET['rest_id'];
$datetime = $_POST['datetime'];
$user_id = $_SESSION['uname'];
$size = $_POST['table-size'];
$sql = "INSERT into reservations(rest_id,user_id,date_time,size) values('$rest_id','$user_id','$datetime','$size');";
if (mysqli_query($conn, $sql)) {
$sql = "SELECT resv_id from reservations where rest_id = $rest_id and user_id = '$user_id' and date_time = '$datetime' and size = $size ORDER BY resv_id DESC;";
$result = mysqli_query($conn, $sql);
if(!$result){
die("QUERY FAILED ".mysqli_error($conn));
}
if(mysqli_num_rows($result) != 0){
$row = mysqli_fetch_assoc($result);
$resv_id = $row['resv_id'];
}
header("refresh:0; url=resv_SMS.php?resv_id=$resv_id");
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
?>