-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathupdate-cart.php
More file actions
50 lines (29 loc) · 727 Bytes
/
Copy pathupdate-cart.php
File metadata and controls
50 lines (29 loc) · 727 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
//if (session_status() !== PHP_SESSION_ACTIVE) {session_start();}
if(!isset($_SESSION))
{
session_start();
}
include 'connection.php';
$conn = Connect();
$F_ID = $_GET['id'];
$action = $_GET['action'];
$sql = "SELECT quantity FROM food WHERE F_id = ".$F_ID;
$result = mysqli_query($conn, $sql);
if($result){
if($obj = mysqli_fetch_assoc($result)) {
switch($action) {
case "add":
if($_SESSION['cart'][$F_ID]+1 <= $row["quantity"])
$_SESSION['cart'][$F_ID]++;
break;
case "remove":
$_SESSION['cart'][$F_ID]--;
if($_SESSION['cart'][$F_ID] == 0)
unset($_SESSION['cart'][$F_ID]);
break;
}
}
}
header("location:cart.php");
?>