-
Notifications
You must be signed in to change notification settings - Fork 0
/
payment.php
45 lines (32 loc) · 1.08 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
<?php
session_start();
if (!isset($_SESSION['username'])) {
header("Location: hks.php");
exit();
}
include 'db_connect.php';
if (isset($_GET['booking_id'])) {
$booking_id = $_GET['booking_id'];
$sql = "SELECT * FROM rooms WHERE id = ? AND username = ? AND payment_status = 'pending'";
$stmt = $conn->prepare($sql);
$stmt->bind_param("is", $booking_id, $_SESSION['username']);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$payment_number = $row['payment_number'];
echo "Your payment number is: " . $payment_number . "<br>";
echo "Payment successful!";
$sql_update = "UPDATE rooms SET payment_status = 'confirmed' WHERE id = ?";
$stmt_update = $conn->prepare($sql_update);
$stmt_update->bind_param("i", $booking_id);
$stmt_update->execute();
header("Location: Dashboard.php");
exit();
} else {
echo "Invalid booking or already paid.";
}
$stmt->close();
}
$conn->close();
?>