-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainhtml.php
140 lines (127 loc) · 4.11 KB
/
mainhtml.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
// Start the session at the very beginning of your script
session_start();
// Define your database connection parameters
$servername = "localhost";
$username = "Atharav";
$password = "Atharav@31";
$database = "project";
// Create a database connection
$conn = new mysqli($servername, $username, $password, $database);
// Check if the database connection is successful
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve form input data
$location = $_POST["location"];
$Type = $_POST["Type"];
$date = $_POST["date"];
$time = $_POST["time"];
$persons = $_POST["persons"];
// Store form input data in session variables
$_SESSION["location"] = $location;
$_SESSION["Type"] = $Type;
$_SESSION["date"] = $date;
$_SESSION["time"] = $time;
$_SESSION["persons"] = $persons;
}
// Fetch locations from the "hotel" table
$sql = "SELECT DISTINCT location FROM hotel";
$result = $conn->query($sql);
$locationOptions = "";
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$locationName = $row["location"];
$locationOptions .= "<option value='$locationName'>$locationName</option>";
}
}
// Close the database connection
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="main.css">
<title>My Profile Page</title>
</head>
<body>
<form action="" method="post">
<nav>
<div>
<a href="historyhtml.php">History</a>
<a href="cancel.pdf">Cancellation Policy</a>
<a href='checkstatus.html'>Check Status</a>
</div>
<div class="profile-option">
<a href="logout.php">Logout</a>
</div>
</nav>
<div class="flex-container">
<div class="page-content">
<h1>Select Your Desirable Hotel</h1>
<div>
<label for="location">Location:</label>
<select id="location" name="location">
<option value="Select">Select</option>
<?php echo $locationOptions; ?>
</select>
<label>Type:</label>
<div class="flex">
<input type="radio" id="Veg" name="Type" value="Veg" required>
<label for="Veg">Veg</label>
<input type="radio" id="Non-Veg" name="Type" value="Non-Veg" required>
<label for="Non-Veg">Non-Veg</label>
<input type="radio" id="Both" name="Type" value="Both" required>
<label for="Both">Both</label>
</div>
</div>
<div>
<label for="date">Date:</label>
<input type="date" id="date" name="date" min="<?= date('Y-m-d') ?>" required>
</div>
<div>
<label for="time">Time:</label>
<input type="time" id="time" name="time" required>
<!-- <input type="time" id="time" name="time" min="10:00" max="22:00" required> -->
</div>
<div>
<label for "persons">Number of Persons:</label>
<input type="number" id="persons" name="persons" min="1" max="50" required>
</div>
<button type="submit">Fetch Hotels</button>
</div>
<div class="hotel-list">
<h2>Hotels</h2>
<table id="hotel-table">
<thead>
<tr>
<th>Hotel Name</th>
<th>Type</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php include("main.php"); ?>
<?php
// Check if the order placed flag is set in the session
if (isset($_SESSION["order_placed"]) && $_SESSION["order_placed"] === true) {
// Display an alert
echo '<script>alert("Your order has been placed!");</script>';
// Reset the order placed flag
$_SESSION["order_placed"] = false;
}
?>
</tbody>
</table>
</div>
</div>
</form>
<footer>
<p>© 2023 BookMyPlate. All rights reserved.</p>
</footer>
</body>
</html>