-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubmit_booking.php
41 lines (35 loc) · 1023 Bytes
/
submit_booking.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
<?php
// Retrieve form values
$student_id = $_POST['student_id'];
$lecture_hall_number = $_POST['lecture_hall_number'];
$hours = $_POST['hours'];
// Database connection settings
$servername = "localhost";
$username = "root";
$password = "Nisa2001";
$dbname = "CGP";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Prepare and bind SQL statement
$stmt = $conn->prepare("INSERT INTO lecture_hall_bookings (student_id, lecture_hall_number, hours) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $student_id, $lecture_hall_number, $hours);
// Execute SQL statement
if ($stmt->execute()) {
// Close statement
$stmt->close();
// Close connection
$conn->close();
// Redirect to success page
header("Location: success.html");
exit();
} else {
// Provide error message
echo "Error: Failed to insert data.";
}
// Close connection
$conn->close();
?>