0

$_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>

Edited by happygeek: database login info obfuscated

2
Contributors
3
Replies
27
Views
3 Years
Discussion Span
Last Post by ryantroop
0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.