how to use php self and passing information to other pages

engoman

New Member
I'm doing a little project that acts like a cart. When I click this link:\[code\]echo "<td><a href=http://stackoverflow.com/"$_SERVER[PHP_SELF]?action=zero&commitbuy.php?ids=$id&qoh=$qtyhand&qtb=$quantity\">ok</a></td>";\[/code\]I want the program to perform the action zero, which will delete the product from the cart table,when I click the ok link:\[code\]<?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; }?>\[/code\]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:\[code\]$_SERVER[PHP_SELF]?action=zero\[/code\]to this one:\[code\] echo "<td><a href=http://stackoverflow.com/"commitbuy.php?ids=$id&qoh=$qtyhand&qtb=$quantity\">ok</a></td>";\[/code\]
 
Back
Top