-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_refund.php
32 lines (26 loc) · 1.04 KB
/
process_refund.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
<?php
session_start();
require('inc/db_config.php');
if (!(isset($_SESSION['login']) && $_SESSION['login'] == true)) {
redirect('index.php');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Sanitize and validate inputs
$booking_id = filter_var(trim($_POST['booking_id']), FILTER_VALIDATE_INT);
$booking_price = filter_var(trim($_POST['booking_price']), FILTER_VALIDATE_FLOAT);
$user_id = $_SESSION['uId'];
if ($booking_id === false || $booking_price === false) {
die('Invalid input data.');
}
// Insert refund details into refunds table
// Delete the booking
$update_booking = mysqli_query($con, "UPDATE booking_order SET is_deleted = 1 WHERE booking_id = '$booking_id' AND user_id = '$user_id'");
if ($update_booking) {
$_SESSION['message'] = "Refund requested successfully.";
} else {
$_SESSION['message'] = "Failed to delete the booking.";
}
} else {
$_SESSION['message'] = "Failed to request refund.";
}
header('Location: bookings.php');