-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBooking.php
More file actions
206 lines (179 loc) · 7.16 KB
/
Booking.php
File metadata and controls
206 lines (179 loc) · 7.16 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Booking</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Roboto', sans-serif;
background-image: url('abstract art.jpeg');
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
color: #333;
}
.form-container {
background-color: rgba(255, 255, 255, 0.9);
padding: 30px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 350px;
text-align: center;
animation: fadeIn 1s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.form-container h1 {
margin-bottom: 20px;
font-size: 24px;
color: #444;
color: #6A1B9A; /* Purple */
}
.form-container label {
font-weight: 500;
display: block;
margin-bottom: 5px;
text-align: left;
}
.form-container input[type="text"],
.form-container input[type="number"],
.form-container input[type="email"],
.form-container input[type="date"],
.form-container input[type="tel"] {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}
.form-container input[type="submit"] {
width: 100%;
padding: 10px;
background-color: #333; /* Dark grey */
border: none;
border: radius 3px;;
color:#444;
font-size: 16px;
font-weight: 500;
cursor: pointer;
transition: background-color 0.3s;
margin-bottom: 10px;
}
.form-container input[type="submit"]:hover {
background-color: #E64A19; /* Darker orange */
}
.form-container input[type="submit"]:nth-child(2) {
background-color: #2196F3; /* Blue */
}
.form-container input[type="submit"]:nth-child(2):hover {
background-color: #1976D2; /* Darker blue */
}
.form-container input[type="submit"]:nth-child(3) {
background-color: #4CAF50; /* Green */
}
.form-container input[type="submit"]:nth-child(3):hover {
background-color: #388E3C; /* Darker green */
}
</style>
</head>
<body>
<div class="form-container">
<h1>Booking Details</h1>
<form method="POST" action="">
<label for="id">Booking ID (for Update/Delete)</label>
<input type="number" id="id" name="id" placeholder="Booking ID">
<label for="fn">Fullname</label>
<input type="text" id="fn" name="fullname" placeholder="Fullname" required>
<label for="age">Age</label>
<input type="number" id="age" name="age" placeholder="Age" required>
<label for="email">Email</label>
<input type="email" id="email" name="email" placeholder="Email address" required>
<label for="no_of_people">Number of people</label>
<input type="number" id="no_of_people" name="no_of_people" placeholder="Number of people" required>
<label for="date">Date</label>
<input type="date" id="date" name="date" required>
<label for="children">Number of children</label>
<input type="number" id="children" name="children" placeholder="Number of children" required>
<label for="phone">Phone number</label>
<input type="tel" id="phone" name="phone" placeholder="Phone number" required>
<input type="hidden" name="action" value="create">
<input type="submit" value="Create Booking">
<input type="hidden" name="action" value="update">
<input type="submit" value="Update Booking">
<input type="hidden" name="action" value="delete">
<input type="submit" value="Delete Booking">
</form>
</div>
<?php
// Enable error reporting
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include 'connection.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$action = $_POST['action'];
$id = isset($_POST['id']) ? $_POST['id'] : null;
$fullname = isset($_POST['fullname']) ? $_POST['fullname'] : null;
$age = isset($_POST['age']) ? $_POST['age'] : null;
$email = isset($_POST['email']) ? $_POST['email'] : null;
$no_of_people = isset($_POST['no_of_people']) ? $_POST['no_of_people'] : null;
$date = isset($_POST['date']) ? $_POST['date'] : null;
$children = isset($_POST['children']) ? $_POST['children'] : null;
$phone = isset($_POST['phone']) ? $_POST['phone'] : null;
if ($action == "create") {
// Create a new booking
$stmt = $conn->prepare("INSERT INTO guest (guest_name, age, email, people, booking_date, children, phone) VALUES (?, ?, ?, ?, ?, ?, ?)");
if ($stmt === false) {
die("Error preparing the statement: " . $conn->error);
}
$stmt->bind_param("sisissi", $fullname, $age, $email, $no_of_people, $date, $children, $phone);
if ($stmt->execute()) {
echo "Booking successful!";
} else {
echo "Error: " . $stmt->error;
}
$stmt->close();
} elseif ($action == "update" && $id) {
// Update an existing booking
$stmt = $conn->prepare("UPDATE guest SET guest_name=?, age=?, email=?, people=?, booking_date=?, children=?, phone=? WHERE id=?");
if ($stmt === false) {
die("Error preparing the statement: " . $conn->error);
}
$stmt->bind_param("sisissii", $fullname, $age, $email, $no_of_people, $date, $children, $phone, $id);
if ($stmt->execute()) {
echo "Booking updated successfully!";
} else {
echo "Error: " . $stmt->error;
}
$stmt->close();
} elseif ($action == "delete" && $id) {
// Delete a booking
$stmt = $conn->prepare("DELETE FROM guest WHERE id=?");
if ($stmt === false) {
diqe("Error preparing the statement: " . $conn->error);
}
$stmt->bind_param("i", $id);
if ($stmt->execute()) {
echo "Booking deleted successfully!";
} else {
echo "Error: " . $stmt->error;
}
$stmt->close();
}
// Close the connection
$conn->close();
}
?>
</body>
</html>