-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove.php
More file actions
26 lines (22 loc) · 945 Bytes
/
remove.php
File metadata and controls
26 lines (22 loc) · 945 Bytes
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
<?php
session_start();
if(isset($_SESSION['id'])){}
else{
echo '<script>window.location.href="/"</script>';
}
$conn = pg_Connect("user=postgres password=rhkgkr6 dbname=mpharam");
$query = "select order_id from usertoorder where user_id=".$_SESSION['id']." and status='current';";
$result = pg_query($conn, $query);
$row = pg_fetch_row($result);
$order_id = $row[0];
$query = "select quantity from ordertoproduct where order_id=".$order_id." and product_id=".$_GET['id'].";";
$result = pg_query($conn, $query);
$row = pg_fetch_row($result);
$quantity = $row[0];
$query = "delete from ordertoproduct where order_id=".$order_id." and product_id=".$_GET['id'].";";
$result = pg_query($conn, $query);
$query = "update products set noitems = noitems + ".$quantity." where id=".$_GET['id'].";";
$result = pg_query($conn, $query);
echo '<script>alert("Successfully removed from cart")</script>';
echo '<script>window.location.href="/"</script>';
?>