-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbook_form.php
43 lines (33 loc) · 1.02 KB
/
book_form.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
<?php
// Database connection settings
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "book_db";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Get form data
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$location = $_POST['location'];
$guests = $_POST['guests'];
$arrivals = $_POST['arrivals'];
$leaving = $_POST['leaving'];
// Insert data into the database
$sql = "INSERT INTO bookings (name, email, phone, address, location, guests, arrivals, leaving)
VALUES ('$name', '$email', '$phone', '$address', '$location', '$guests', '$arrivals', '$leaving')";
if ($conn->query($sql) === TRUE) {
echo "Booking successfully submitted!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
//confirmation Email
// Close the connection
$conn->close();
?>