File: /home/bigisxfd/public_html/cowork/checkout_booking.php
<?php
// Include necessary files
include_once("functions.php");
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["bookingId"])) {
$bookingId = $_POST["bookingId"];
// Update the booking status to inactive
$updateQuery = "UPDATE Bookings SET active = 0 WHERE bookingid = ?";
$updateStmt = $conn->prepare($updateQuery);
$updateStmt->bind_param("i", $bookingId);
if ($updateStmt->execute()) {
// Booking checkout successful
echo "Booking checked out successfully.";
} else {
// Error occurred while updating the booking
echo "Error checking out booking.";
}
$updateStmt->close();
} else {
// Invalid request
echo "Invalid request.";
}
// Close the database connection
$conn->close();
?>
<script>
// Redirect back to bookings.php after a delay
setTimeout(function() {
window.location.href = "bookings.php";
}, 1000); // Redirect after 2 seconds (adjust as needed)
</script>