-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDeleteHandler.php
95 lines (62 loc) · 2.28 KB
/
DeleteHandler.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php session_start();
//delete product btn
if(isset($_POST["deleteProductBtn"])){
$id = $_GET["id"];
$con = mysqli_connect("localhost", "root", "", "novatech_database", "3306");
if(!$con){
die("Sorry, you can't connect to the database.");
}
$sql = "DELETE FROM `product_tbl` WHERE `productID` =" . $_GET["id"];
if(mysqli_query($con, $sql)){
echo "<script>
alert('Deleted product');
window.location.href = 'admin.php#my-products';
</script>";
}
}
//delete user btn
if(isset($_POST["deleteUserBtn"])){
$id = $_GET["id"];
$con = mysqli_connect("localhost", "root", "", "novatech_database", "3306");
if(!$con){
die("Sorry, you can't connect to the database.");
}
$sql = "DELETE FROM `user_tbl` WHERE `userID` =" . $_GET["id"];
if(mysqli_query($con, $sql)){
echo "<script>
alert('Deleted user');
window.location.href = 'admin.php#users';
</script>";
}
}
//delete from wishlist btn
if(isset($_POST["wishlistBtn"])){
$id = $_GET["id"];
$con = mysqli_connect("localhost", "root", "", "novatech_database", "3306");
if(!$con){
die("Sorry, you can't connect to the database.");
}
$sql = "DELETE FROM `wishlist_tbl` WHERE `itemID` =" . $_GET["id"];
if(mysqli_query($con, $sql)){
echo "<script>
alert('Removed from wishlist');
window.location.href = 'profile.php#my-products';
</script>";
}
}
//delete from cart btn
if(isset($_POST["cartDeleteBtn"])){
$id = $_GET["id"];
$con = mysqli_connect("localhost", "root", "", "novatech_database", "3306");
if(!$con){
die("Sorry, you can't connect to the database.");
}
$sql = "DELETE FROM `cart_tbl` WHERE `cartID` =" . $_GET["id"];
if(mysqli_query($con, $sql)){
echo "<script>
alert('Removed from cart');
window.location.href = 'cart.php';
</script>";
}
}
?>