Help with PHP???

martinatkinson

Registered
Hi,

I am having trouble with a PHP script I am working on. It is a shopping cart script using sessions to store the items from the cart. Problem is, after it registers the first item no more items will register correctly :(

Take a look at the code below and see if you can see anything:

PHP:
$ses_cart_id = $_SESSION["ses_cart_id"];
	$ses_cart_name = $_SESSION["ses_cart_name"];
	$ses_cart_qty = $_SESSION["ses_cart_qty"];
	
	$ses_cart_items = $_SESSION["ses_cart_items"];

	if ($_GET['name']!="") {
   		if (session_is_registered("ses_cart_items")) {
   			$cart_position_counter=0;
			$double=0;
			
			if ($ses_cart_items>0){
				foreach ($ses_cart_name as $cart_item) {
					if ($cart_item==$_GET['name']) {
						$double=1;
		      	   		$cart_position=$cart_position_counter;
		     	 	}
		     	 	
		    	 	$cart_position_counter++;
		   		}
			}
		
			if ($double!=1) {
				$ses_cart_id[]=$_GET['id'];
				$ses_cart_name[]=$_GET['name'];
				$ses_cart_qty[]=1;
				
				$ses_cart_items++;
			}
		} else {
			$ses_cart_id[0]=$_GET['id'];
			$ses_cart_name[0]=$_GET['name'];
			$ses_cart_qty[0]=1;
			
			$ses_cart_items=1;
			
			session_register("ses_cart_id");
			session_register("ses_cart_name");
			session_register("ses_cart_qty");
			
			session_register("ses_cart_items");
		}
	}
	
	// Delete Items from Cart
	if ($_GET['action']=="delete") {
		array_splice ($_SESSION["ses_cart_id"], $_GET['item'], 1);
		array_splice ($_SESSION["ses_cart_name"], $_GET['item'], 1);
		array_splice ($_SESSION["ses_cart_qty"], $_GET['item'], 1);
		
		$_SESSION["ses_cart_items"]--;
	}

Any suggestions? Thanks in advance!
 
Back
Top