All pastes #192530 Raw Edit

Kanzie

public php v1 · immutable
·published 2006-10-06 00:39 UTC
rendered paste body
// try it at: http://kanzie.com/bgc/rpc.php?mode=addCart&productid=14,15,16,14,14,15,14	if ($_GET['mode'] == "addCart") {		if (isset($_GET['productid'])) {			$products = explode(",",$_GET['productid']);			var_dump($products);					if (isset($products)) {			if (!isset($_SESSION['cart'])) {				$_SESSION['cart'] = array();				echo "<br />SESSION Cart not set, setting it <br />";			} 			foreach ($products as $key) {				if (array_key_exists($key,$_SESSION['cart'])) {					$_SESSION['cart'][$key]++;					echo "Key " . $key . " exists, incrementing value, value now " . $_SESSION['cart'][$key] . "<br />";				} else {					$_SESSION['cart'] = array($key => 1);					echo "no previous key for " . $key .", setting value 1<br />";				}			} // for every productid in productid-POST		} // no products set in the products= POST		} // productid-POST is not set	} // mode is not "addCart"	echo("<br /><br />");	print_r(array_values($_SESSION['cart']));