remove items from shopping cart session
Posted: Wed Oct 03, 2007 5:25 pm
hi all,
i have a shopping cart that works but i want to add an option to delete a product. here is what i have tried so far...
The ADD to cart bit....
the carts remove item button
the form on the cart that send the id of the product selected.
Then the php script that it posts to is...
?>
though no error is displayed and the script is receiving the id from the form???
any help would be appreciated,
cheers
i have a shopping cart that works but i want to add an option to delete a product. here is what i have tried so far...
The ADD to cart bit....
Code: Select all
<?php
session_start();
if (count($_SESSION["cart"]) < 1) {
$_SESSION["cart"] = array();
}
$_SESSION["cart"][] = $_POST["itemid"];
header("location:cart.php");
?>the form on the cart that send the id of the product selected.
Code: Select all
<form id="id" name="id" method="post" action="/remove_item.php">
<input name="id" type="hidden" id="id" value="<? echo $info['id']; ?>" />
<input name="Submit" type="submit" class="formbox" value="Remove" />
</form>Code: Select all
<?php
$_SESSION['cart'][] = $itemid;
$id=$_POST['id'];
unset($_SESSION['cart'][$id]);
header("location:cart.php");though no error is displayed and the script is receiving the id from the form???
any help would be appreciated,
cheers