-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment.php
49 lines (44 loc) · 1.95 KB
/
payment.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
<?php
include('db_config.php');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$first_name = $_POST["first_name"];
$last_name = $_POST["last_name"];
$email = $_POST["email"];
$telephone = $_POST["telephone"];
$from_date = $_POST["from_date"];
$to_date = $_POST["to_date"];
$bike_id = $_POST["bike_id"]; // Added to capture the selected bike
$availability_status = $_POST["availability_status"]; // Added to capture availability status
// Insert user data into the "users" table
$sql_users = "INSERT INTO users (first_name, last_name, email, telephone, from_date, to_date)
VALUES ('$first_name', '$last_name', '$email', '$telephone', '$from_date', '$to_date')";
// Insert reservation data into the "manage" table
$sql_manage = "INSERT INTO manage (User_ID, Bike_ID, Booking_Date, Return_Date)
VALUES (LAST_INSERT_ID(), '$bike_id', '$from_date', '$to_date')";
if (mysqli_query($conn, $sql_users) && mysqli_query($conn, $sql_manage)) {
// Update the availability status of the selected bike to 'Booked' in the 'bikes' table
$updateBikeSQL = "UPDATE bikes SET Availability_Status = 'Booked' WHERE Bike_ID = $bike_id";
if (mysqli_query($conn, $updateBikeSQL)) {
echo "<p>Thank you, $first_name, for booking a bike. You will be redirected to the payment page.</p>";
// Add payment processing logic or redirection to the actual payment gateway here.
} else {
echo "Error updating bike availability status: " . mysqli_error($conn);
}
} else {
echo "Error inserting data: " . mysqli_error($conn);
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Payment Page</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Payment Page</h1>
<a href="index.php">Back to Booking</a>
<!-- This is only for test -->
<a href="admin_bookings.php">Go to admin</a>
</body>
</html>