Hello Everyone,

I have been trying to get this shopping cart working for a while but I honestly do not know where the problem is. Either I am not creating the seseions properly. However, my primary worry it is not displaying the product in the cart. I ahve tried MANY, MANY forums no one knows what's happening?

PHP Code:
<?php
   session_start
();
  

   
// get the product id
   
$DVDID = isset($_GET['DVDID']) ? $_GET['DVDID'] : "";
   
$name = isset($_GET['NameOfTheDVD']) ? $_GET['NameOfTheDVD'] : "";
   require 
"connect.php";
   
$query "SELECT `DVDID`, `NameOfTheDVD`, `Quantity` FROM `DVD`";
   
$stmt $dbhandle->prepare($query);
   
$stmt->execute();

   
/* 
    * check if the 'cart' session array was created
    * if it is NOT, create the 'cart' session array
 . */
   
if(!isset($_SESSION['cart'])){
     
$_SESSION['cart'][$DVDID];
     
$_SESSION['cart'][$name];
     
$_SESSION['cart'][$Quantity];
    
    }

   
// check if the item is in the array, if it is, do not add
   
if(in_array($DVDID$_SESSION['cart'])){
      
// redirect to product list and tell the user it was added to cart
      
header('Location: shop.php?action=exists&DVDID' $DVDID '&name=' $name);
    }

     
// else, add the item to the array
    
else{
    
array_push($_SESSION['cart'][] = $DVDID);
    
// redirect to product list and tell the user it was added to cart
    
header('Location: shop.php?action=add&DVDID' $DVDID '&name=' $name);
    }
    
    
?>
Above is my AddToCart file.

PHP Code:
<?php
     
    
      $action 
= isset($_GET['action']) ? $_GET['action'] : "";
     
      
$name = isset($_GET['NameOfTheDVD']) ? ($_GET['NameOfTheDVD']): "";
      
$DVDID = isset($_GET['DVDID']) ? ($_GET['DVDID']) : "";
      
$Quantity =isset($_GET['Quantity']) ? ($_GET['Quantity']) : "";
      if(
$action=='add'){
         echo 
"<h3>" $DVDID " was added to your cart.</h3>";
     }
      if(
$action=='exists'){
    echo 
"<h3>" $DVDID " already exists in your cart.</h3>";
}
     require 
"connect.php";
  
     
$query "SELECT `DVDID`, `NameOfTheDVD`, `Quantity` FROM `DVD`";
     
$stmt $dbhandle->prepare($query);
     
$stmt->execute();
     
     
$num $stmt->rowCount();
     
     if(
$num>0){
      echo 
"<table border='3' cellpadding='10' position='relative` bottom= '450px';>";//start table
    
        // our table heading
            
echo "<tr>";
            echo 
"<th class='textAlignLeft'>DVD Name</th>";
            echo 
"<th class='textAlignLeft'>DVD ID</th>";
            echo 
"<th>Quantity</th>";
            echo 
"<th>Action</th>";
            echo 
"</tr>";
        
        while (
$row $stmt->fetch(PDO::FETCH_ASSOC)){
           
            
            
//creating new table row per record
                
echo "<tr>";
                
                echo 
"<td>" $row['NameOfTheDVD'] . "</td>";
                echo 
"<td>" $row['DVDID'] . "</td>";
                echo 
"<td>" $row['Quantity'] . "</td>";
                echo 
"<td class='textAlignCenter'>";
                    echo 
"<a href='AddToCart.php?id={$DVDID}&name={$name}' class='customButton'>";
                        echo 
"<img src='Add.png' title='Add To Cart' />";
                    echo 
"</a>";
                echo 
"</td>";
            echo 
"</tr>";
            

        }
        
    echo 
"</table>";
        }

        
// no products in the database
        
else{
          echo 
"No products found.";
        }
        
        
print_r($_GET);

     
?>
Above is my shop page where the products are listed.

HELPPPP!!!!