I'm doing a little project that acts like a cart. When I click this link:
echo "<td><a href=\"$_SERVER[PHP_SELF]?action=zero&commitbuy.php?ids=$id&qoh=$qtyhand&qtb=$quantity\">ok</a></td>";
I want the program to perform the action zero, which will delete the product from the cart table,when I click the ok link:
<?php
$product_id = $_GET['id'];
$action = $_GET['action'];
if($product_id && !productExists($product_id)) {
die("Error. Product Doesn't Exist");
}
switch($action) {
case "add":
$_SESSION['cart'][$product_id]++;
break;
case "remove":
$_SESSION['cart'][$product_id]--;
if($_SESSION['cart'][$product_id] == 0) unset($_SESSION['cart'][$product_id]);
break;
case "zero":
$_SESSION['cart'][$product_id]==0;
break;
case "empty":
unset($_SESSION['cart']);
break;
}
?>
Then also, commitbuy.php would update the quantity of that certain product. What can you suggest that I would do with this. It doesn't seem to work. When I add this code:
$_SERVER[PHP_SELF]?action=zero
to this one:
echo "<td><a href=\"commitbuy.php?ids=$id&qoh=$qtyhand&qtb=$quantity\">ok</a></td>";