forked from prabhxjottsingh/codechef-cu-chapter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbook.php
More file actions
42 lines (32 loc) · 1.07 KB
/
book.php
File metadata and controls
42 lines (32 loc) · 1.07 KB
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
40
41
42
<?php
$name = $_POST['name'];
$checkin = $_POST['checkin'];
$checkout = $_POST['checkout'];
$adults = $_POST['adults'];
$roomtype=$_POST["roomtype"];
$rooms = $_POST['rooms'];
$conn = new mysqli('localhost','root','','book');
if($conn->connect_error){
die('Connection Failed :'.$conn->connect_error);
echo "connectionfailed ";
}
else{
$stmt =$conn->prepare("insert into booking(name ,checkin , checkout , adults , roomtype , rooms)
values(?,?,?,?,?,?)");
$stmt->bind_param("sssisi", $name ,$checkin,$checkout,$adults,$roomtype,$rooms);
$stmt->execute();
$sql = "SELECT SUM(`rooms`) AS total FROM `booking`";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_object($result) ;
if($row->total > 50){
echo "<script>alert('no rooms available')</script>";
echo "<script>window.location='final.html'</script>";
}
else{
echo "<script>alert('room booked')</script>";
echo "<script>window.location='final.html'</script>";
}
$stmt->close();
$conn->close();
}
?>