Coming from a page "show_book.php"
we have the following button to add an item to the cart
display_button("show_cart.php?new=$isbn", "add-to-cart", "Add ".$book["title"]." To My Shopping Cart");
when this button is pressed we go to show_cart.php" with the isbn being passed as a parameter.
example of url: show_cart.php?new=0672317842
Show_Cart.php begins with the following code
if($new)
{
//new item selected
if(!session_is_registered("cart"))
{
$cart = array();
session_register("cart");
$items = 0;
session_register("items");
$total_price = "0.00";
session_register("total_price");
}
if($cart[$new])
$cart[$new]++;
else
$cart[$new] = 1;
$total_price = calculate_price($cart);
$items = calculate_items($cart);
if($cart&&array_count_values($cart))
display_cart($cart);
else
{
echo "<p>There are no items in your cart";
echo "<hr>";
}
How is it that cart is registered when a book is added to the cart?
Please explain this code in laymen terms.
you can view the project @ http://www.caillouette.com/CHAPTER26a/show_book.php?isbn=0672317842
thanks