-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcart_remove.php
39 lines (33 loc) · 1.15 KB
/
cart_remove.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
<?php
session_start();
if(isset($_POST['remove'])){
// print_r($_POST['buyId']);
include_once 'database.php';
if(isset($_SESSION['sessionId'])){
$custId=$_SESSION['sessionId'];
$prodId=$_POST['buyId'];
foreach($_SESSION['cart'] as $key=>$value){
if($value['buyId']==$_POST['buyId']){
unset($_SESSION['cart'][$key]);
}
}
$sql="delete from products_customer where productID=? and customerID =?;";
$stmt= mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)){
echo 'sql error4';
// header("Location: sell_welcome.php?error=sqlerror1");
exit();
}else{
mysqli_stmt_bind_param($stmt, "ss", $prodId,$custId);
mysqli_stmt_execute($stmt);
echo "<script> alert('This product has been removed') </script>";
echo "<script>window.location= 'checkout.php'</script>";
}
}
else{
echo '<script>alert("Pls sign in")</script>';
echo '<script>window.location.href = "checkout.php";</script>';
exit();
}
}
?>