$_GET is empty and this is my code. I dont know what to do

<?php

session_start();

?>
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');

$hostname = "localhost"; 
$username = "xxxxx";
$password = "xxxxx";
$database = "db1104107";
//echo '24';

//connection to the database
try {
    $dbhandle = new PDO("mysql:host={$hostname};database={$database}", $username, $password);
}

//to handle connection error
catch(PDOException $exception){
    echo "Connection error: " . $exception->getMessage();
}

?>

<!DOCTYPE HTML>
<html>

  <head>

      <title>Shopping Cart</title>
        <link type="text/css" rel="stylesheet" href="basket.css" />

  </head>
  <body>
    <?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 "<div>" . $name . " was added to your cart.</div>";
     }

      if($action=='exists'){
       echo "<div>" . $name . " already exists in your cart.</div>";
     }

     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='0'>";//start table

        // our table heading
            echo "<tr>";
            echo "<th class='textAlignLeft'>DVD Name</th>";
            echo "<th>Quantity</th>";
            echo "<th>Action</th>";
            echo "</tr>";

        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
            extract($row);

            //creating new table row per record
                echo "<tr>";
                echo "<td>{$name}</td>";
                echo "<td class='textAlignRight'>{$Quantity}</td>";
                echo "<td class='textAlignCenter'>";
                    echo "<a href='AddToCart.php?id={$DVDID}&name={$name}' class='customButton'>";
                        echo "<img src='images/add-to-cart.png' title='Add To Cart' />";
                    echo "</a>";
                echo "</td>";
            echo "</tr>";
            print_r($_GET);

        }

    echo "</table>";
}

// no products in the database
else{
    echo "No products found.";
}

?>
  </body>

</html>

What URL are you using to access this page?

I have actually solved it. Thanks for your help. Van you tell me if i can delete a part. article

Not after a reply has been made. You can flag it as a bad post, and an admin can change what you need changed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.