session_start(); include("includes/db.php"); include("includes/functions.php"); if($_GET['command']=='add' && $_GET['productid']>0) { $pid=$_REQUEST['productid']; $szid=$_REQUEST['szid']; addtocart($pid,1,$szid); } else if($_REQUEST['command']=='delete' && $_REQUEST['pid']>0){ remove_product($_REQUEST['pid']); } else if($_REQUEST['command']=='clear'){ unset($_SESSION['cart']); } else if($_GET['command']=='update'){ $max=count($_SESSION['cart']); for($i=0;$i<$max;$i++){ $pid=$_SESSION['cart'][$i]['productid']; $q=intval($_REQUEST['product'.$pid]); if($q>0 && $q<=999){ $_SESSION['cart'][$i]['qty']=$q; } else{ $msg='Some proudcts not updated!, quantity must be a number between 1 and 999'; } } } ?>