title: How Can I Insert Data Into Database From A Form Properly?
body: <p>so I've been working on a form using an MVC approach that will insert data into a database using PDO. I have the addWine form, addWine controller, data access model and wine class model. On submission of the form nothing happens and the database isn't populated. Can someone pinpoint what I have done wrong here? </p>
  
  <p>Wine Form</p>
  
  <pre><code>&lt;form action= "" method="POST"&gt;
      &lt;table&gt;
       &lt;b&gt;Fill the form to add new wine&lt;/b&gt;&lt;p&gt;&lt;p&gt;
      &lt;tr&gt;
      &lt;td&gt; Wine ID:     &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name= "wineID"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Wine Country ID: &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="wineCountryID"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Wine Size ID: &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="wineSizeID"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Wine Rating ID: &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="wineRatingID"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Wine Colour ID: &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="wineColourID"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Wine Package ID: &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="winePackageID"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Wine Category ID: &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="wineCategoryID"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Wine Code: &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="wineCode"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Wine Price: &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="wineCountryID"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Wine Description: &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="wineDescription"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Wine Rating: &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="wineRating"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Wine Image: &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="wineImage"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
    &lt;/table&gt;&lt;p&gt;&lt;br&gt;
  
    &lt;center&gt;&lt;input type="submit" name= "addWineButton" value="Add Wine"&gt;&lt;/center&gt;&lt;p&gt;&lt;p&gt;&lt;p&gt;&lt;p&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>Add Wine Controller</p>
  
  <pre><code>&lt;?php
  ini_set('display_errors', 1);
  ini_set('display_startup_errors', 1);
  error_reporting(E_ALL);
  
  session_start();
  require_once('../Model/dataAccess.php');
  require_once('../Model/wine.class.php');
  
  $status = false;
  
  if(isset($_POST["addWineButton"])){
  
  $wineID = $_POST["wineID"];
  $wineCountryID = $_POST["wineCountryID"];
  $wineSizeID = $_POST["wineSizeID"];
  $wineRatingID = $_POST["wineRatingID"];
  $wineColourID = $_POST["wineColourID"];
  $packageID = $_POST["packageID"];
  $wineCategoryID = $_POST["wineCategoryID"];
  $wineCode = $_POST["wineCode"];
  $price = $_POST["price"];
  $description = $_POST["description"];
  $wineRating = $_POST["wineRating"];
  $wineIMG = $_POST["wineIMG"];
  
  $wineAdd = new Wine();
  $wineAdd-&gt;wineID = htmlentities($wineID);
  $wineAdd-&gt;wineCountryID = htmlentities($wineCountryID);
  $wineAdd-&gt;wineSizeID = htmlentities($wineSizeID);
  $wineAdd-&gt;wineRatingID = htmlentities($wineRatingID);
  $wineAdd-&gt;wineColourID = htmlentities($wineColourID);
  $wineAdd-&gt;packageID = htmlentities($packageID);
  $wineAdd-&gt;wineCategoryID = htmlentities($wineCategoryID);
  $wineAdd-&gt;wineCode = htmlentities($wineCode);
  $wineAdd-&gt;price = htmlentities($price);
  $wineAdd-&gt;description = htmlentities($description);
  $wineAdd-&gt;wineRating = htmlentities($wineRating);
  $wineAdd-&gt;wineIMG = htmlentities($wineIMG);
  
  addWine($wineAdd);
  $status = "$description has been updated.";
   }
  ?&gt;
  </code></pre>
  
  <p>Wine Class Model</p>
  
  <pre><code>&lt;?php
  
  class Wine {
  
  
  var $wineID;
  var $wineSizeID;
  var $wineCountryID;
  var $wineRatingID;
  var $wineColourID;
  var $wineCode;
  var $price;
  var $description;
  var $wineRating;
  var $wineIMG;
  var $packageID;
  var $wineCategoryID;
  
  function __get($name){
  return $this-&gt;$name;
  }
  function __set($name,$value){
  $this-&gt;$name=$value;
   }
  }
  ?&gt;
  </code></pre>
  
  <p>Data Access Model</p>
  
  <pre><code>function addWine($wineAdd){
  global $pdo;
  $statement = $pdo-&gt;prepare('INSERT INTO Wine
  (wineID, wineCountryID, wineSizeID, wineRatingID, wineColourID, packageID,
  wineCategoryID, wineCode, price, description, wineRating, wineIMG) VALUES  (?,?,?,?,?,?,?,?,?,?,?,?)');
  $statement-&gt;execute([$wineAdd-&gt;wineID,
                       $wineAdd-&gt;wineCountryID,
                       $wineAdd-&gt;wineSizeID,
                       $wineAdd-&gt;wineRatingID,
                       $wineAdd-&gt;wineColourID,
                       $wineAdd-&gt;packageID,
                       $wineAdd-&gt;wineCategoryID,
                       $wineAdd-&gt;wineCode,
                       $wineAdd-&gt;price,
                       $wineAdd-&gt;description,
                       $wineAdd-&gt;wineRating,
                       $wineAdd-&gt;wineIMG]);
    $statement-&gt;fetch();
    }
  </code></pre>