'Flute', 'cost' => '149.50'); $products['MMS-6289'] = array('name' => 'Trumpet', 'cost' => '199.50'); $products['MMS-3408'] = array('name' => 'Clarinet', 'cost' => '299.50'); // Include cart functions require_once('eg031_cart.php'); // Get the action to perform, hidden variable from from if (isset($_POST['action'])) { $action = $_POST['action']; } else if (isset($_GET['action'])) { $action = $_GET['action']; } else { $action = 'show_add_item'; } // Add or update cart as needed switch($action) { case 'add': add_item($_POST['productkey'], $_POST['itemqty']); include('eg031_cart_view.php'); break; case 'update': $new_qty_list = $_POST['newqty']; foreach($new_qty_list as $key => $qty) { if ($_SESSION['cart12'][$key]['qty'] != $qty) { update_item($key, $qty); } } include('eg031_cart_view.php'); break; case 'show_cart': include('eg031_cart_view.php'); break; case 'show_add_item': include('eg031_add_item_view.php'); break; case 'empty_cart': unset($_SESSION['cart12']); include('eg031_cart_view.php'); break; } ?>