-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
114 lines (99 loc) · 3.19 KB
/
index.php
File metadata and controls
114 lines (99 loc) · 3.19 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
//Daniel Gallagher
// include the header
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['checkin']) && isset($_POST['checkout'])) {
$checkin = $_POST['checkin'];
$checkout = $_POST['checkout'];
// Ensure that check-in date is before check-out date
if (strtotime($checkin) > strtotime($checkout)) {
//echo "<span style='color: red;'>Error: Check-in date cannot be after check-out date.</span>";
echo '<script type="text/javascript">';
echo 'alert("Error: Check-in date cannot be greater than the Check-out date");';
echo 'window.location.href = "index.php";';
echo '</script>';
}
// Ensure that check-out date is not less than check-in date
else if (strtotime($checkout) <= strtotime($checkin)) {
//echo "<span style='color: red;'>Error: Check-out date cannot be before check-in date.</span>";
echo '<script type="text/javascript">';
echo 'alert("Error: Check-Out date cannot be less or equal than the Check-In date");';
echo 'window.location.href = "index.php";';
echo '</script>';
} else {
// Calculate the number of days between the check-in and check-out dates
$datediff = strtotime($checkout) - strtotime($checkin);
$num_days = round($datediff / (60 * 60 * 24));
// Store the check-in, check-out, and number of days in session variables
$_SESSION['checkin'] = $checkin;
$_SESSION['checkout'] = $checkout;
$_SESSION['num_days'] = $num_days;
// Redirect to another PHP file
header('Location: AvailableRooms.php');
exit;
}
}
}
include('header.php');
?>
<div id = "h1PageOne">
<h1 >Welcome to iHotel</h1>
</div>
<div class = "wrapperForCal">
<form method="post" action="index.php" class="booking-form">
<label for="checkin">Check-in date:</label>
<input type="date" id="checkin" name="checkin">
<label for="checkout">Check-out date:</label>
<input type="date" id="checkout" name="checkout">
<input type="submit" value="See Availability">
</form>
</div>
<div class = firstPagePic>
<a href = "bookNow.php"><img src ="images/hotelpic.jpg" ></a>
</div>
<?php
//echo $_SESSION['customerusername'];
?>
</div>
<?php
// include the footer
include('footer.php');
?>
<style>
<style>
.wrapperForCal {
max-width: 200px; /* Adjust this value as needed */
margin: 0 auto;
display: flex;
justify-content: flex-start;
}
.booking-form {
display: flex;
flex-direction: column;
align-items: center;
}
.booking-form label {
margin: 10px 0;
}
.booking-form input[type="date"] {
padding: 5px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
.booking-form input[type="submit"] {
padding: 10px 20px;
font-size: 16px;
background-color: #007bff;
border: none;
border-radius: 5px;
color: #fff;
cursor: pointer;
margin-top: 20px;
}
.booking-form input[type="submit"]:hover {
background-color: #0056b3;
}
</style>
</style>