-
Notifications
You must be signed in to change notification settings - Fork 0
/
book_db.php
51 lines (32 loc) · 1.19 KB
/
book_db.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
<?php
// Retrieve data from form submission
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$nic = $_POST['nic'];
$phonenumber = $_POST['phonenumber'];
$address = $_POST['address'];
$bookname = $_POST['bookname'];
$servername = "localhost";
$username = "root";
$password = "";
$database = "library";
// Create connection
$conn = new mysqli($servername, $username, $password, $database);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Insert data into the database
$sql = "INSERT INTO book_details (fullname, email, nic, phonenumber, address, bookname) VALUES ('$fullname', '$email', '$nic', '$phonenumber', '$address', '$bookname')";
$stmt = $conn->prepare("INSERT INTO book_details (fullname, email, nic, phonenumber, address, bookname) VALUES (?, ?, ?, ?, ?, ?)");
$stmt->bind_param("ssssss", $fullname, $email, $nic, $phonenumber, $address, $bookname);
if ($stmt->execute()) {
// Redirect to payment.php after successful database insertion
header("Location: payment.php");
exit();
} else {
echo "Error: " . $stmt->error;
}
$conn->close();
$stmt->close();
?>