-
Notifications
You must be signed in to change notification settings - Fork 43
/
reservation.php
225 lines (123 loc) · 5.49 KB
/
reservation.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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?php
session_start();
require "admin/includes/functions.php";
require "admin/includes/db.php";
$msg = "";
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST['submit'])) {
$guest = preg_replace("#[^0-9]#", "", $_POST['guest']);
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
$phone = preg_replace("#[^0-9]#", "", $_POST['phone']);
$date_res = htmlentities($_POST['date_res'], ENT_QUOTES, 'UTF-8');
$time = htmlentities($_POST['time'], ENT_QUOTES, 'UTF-8');
$suggestions = htmlentities($_POST['suggestions'], ENT_QUOTES, 'UTF-8');
if($guest != "" && $email && $phone != "" && $date_res != "" && $time != "" && $suggestions != "") {
$check = $db->query("SELECT * FROM reservation WHERE no_of_guest='".$guest."' AND email='".$email."' AND phone='".$phone."' AND date_res='".$date_res."' AND time='".$time."' LIMIT 1");
if($check->num_rows) {
$msg = "<p style='padding: 15px; color: red; background: #ffeeee; font-weight: bold; font-size: 13px; border-radius: 4px; text-align: center;'>You have already placed a reservation with the same information</p>";
}else{
$insert = $db->query("INSERT INTO reservation(no_of_guest, email, phone, date_res, time, suggestions) VALUES('".$guest."', '".$email."', '".$phone."', '".$date_res."', '".$time."', '".$suggestions."')");
if($insert) {
$ins_id = $db->insert_id;
$reserve_code = "UNIQUE_$ins_id".substr($phone, 3, 8);
$msg = "<p style='padding: 15px; color: green; background: #eeffee; font-weight: bold; font-size: 13px; border-radius: 4px; text-align: center;'>Reservation placed successfully. Your reservation code is $reserve_code. Please Note that reservation expires after one hour</p>";
}else{
$msg = "<p style='padding: 15px; color: red; background: #ffeeee; font-weight: bold; font-size: 13px; border-radius: 4px; text-align: center;'>Could not place reservation. Please try again</p>";
}
}
}else{
$msg = "<p style='padding: 15px; color: red; background: #ffeeee; font-weight: bold; font-size: 13px; border-radius: 4px; text-align: center;'>Incomplete form data or Invalid data type</p>";
print_r($_POST);
}
}
}
?>
<!Doctype html>
<html lang="en">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<head>
<title>MFORS</title>
<link rel="stylesheet" href="css/main.css" />
<script src="js/jquery.min.js" ></script>
<script src="js/myscript.js"></script>
</head>
<body>
<?php require "includes/header.php"; ?>
<div class="parallax" onclick="remove_class()">
<div class="parallax_head">
<h2>Reserve</h2>
<h3>Table Space</h3>
</div>
</div>
<div class="content" onclick="remove_class()">
<div class="inner_content">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" class="hr_book_form">
<h2 class="form_head"><span class="book_icon">BOOK A TABLE</span></h2>
<p class="form_slg">We offer you the best reservation services</p>
<?php echo "<br/>".$msg; ?>
<div class="left">
<div class="form_group">
<label>No of Guest</label>
<input type="number" placeholder="How many guests" min="1" name="guest" id="guest" required>
</div>
<div class="form_group">
<label>Email</label>
<input type="email" name="email" placeholder="Enter your email" required>
</div>
<div class="form_group">
<label>Phone Number</label>
<input type="text" name="phone" placeholder="Enter your phone number" required>
</div>
<div class="form_group">
<label>Date</label>
<input type="date" name="date_res" placeholder="Select date for booking" required>
</div>
<div class="form_group">
<label>Time</label>
<input type="time" name="time" placeholder="Select time for booking" required>
</div>
</div>
<div class="left">
<div class="form_group">
<label>Suggestions <small><b>(E.g No of Plates, How you want the setup to be)</b></small></label>
<textarea name="suggestions" placeholder="your suggestions" required></textarea>
</div>
<div class="form_group">
<input type="submit" class="submit" name="submit" value="MAKE YOUR BOOKING" />
</div>
</div>
<p class="clear"></p>
</form>
</div>
</div>
<div class="content" onclick="remove_class()">
<div class="inner_content">
<div class="contact">
<div class="left">
<h3>LOCATION</h3>
<p>Buk New Site, New Campus</p>
<p>Kano State</p>
</div>
<div class="left">
<h3>CONTACT</h3>
<p>08054645432, 07086898709</p>
<p>Website@gmail.com</p>
</div>
<p class="left"></p>
<div class="icon_holder">
<a href="#"><img src="image/icons/Facebook.png" alt="image/icons/Facebook.png" /></a>
<a href="#"><img src="image/icons/Google+.png" alt="image/icons/Google+.png" /></a>
<a href="#"><img src="image/icons/Twitter.png" alt="image/icons/Twitter.png" /></a>
</div>
</div>
</div>
</div>
<div class="footer_parallax" onclick="remove_class()">
<div class="on_footer_parallax">
<p>© <?php echo strftime("%Y", time()); ?> <span>MyRestaurant</span>. All Rights Reserved</p>
</div>
</div>
</body>
</html>