-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeletePurchase.php
More file actions
44 lines (31 loc) · 1.11 KB
/
DeletePurchase.php
File metadata and controls
44 lines (31 loc) · 1.11 KB
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
<?php
$passworddb = "";
if (isset($_GET['PurchaseTransactionID'])) {
$PurchaseTransactionID = $_GET['PurchaseTransactionID'];
if (empty($PurchaseTransactionID)) {
die("PurchaseTransactionID is required.");
}
$connection = mysqli_connect("localhost", "root", "", "library");
if (!$connection) {
die("Connection failed: " . mysqli_connect_error());
}
$query = "DELETE FROM `purchase_transaction` WHERE `PurchaseTransactionID` = ?";
$stmt = mysqli_prepare($connection, $query);
if ($stmt) {
mysqli_stmt_bind_param($stmt, "i", $PurchaseTransactionID);
if (mysqli_stmt_execute($stmt)) {
echo "Book with ID $PurchaseTransactionID has been deleted successfully.";
header("Location: Purchase.php");
exit();
} else {
echo "Error deleting book: " . mysqli_stmt_error($stmt);
}
mysqli_stmt_close($stmt);
} else {
echo "Error preparing statement: " . mysqli_error($connection);
}
mysqli_close($connection);
} else {
echo "PurchaseTransactionID is missing.";
}
?>