title: php- data not entered to database
body: <p>I am trying to enter 3 different data to a mysql database 'pages'
  The first 2 data is submitted to the database but the third 'dname' is not.
  <br> The <code>$_SESSION['dname']</code> contains the value to be added to the column 'dname'<br>
  <br> The php looks like:</p>
  
  <pre><code>   if (isset($_POST['submit']))
  {   
      $menulabel = $_POST['menulabel'];
      $content = $_POST['content'];
      $dname = $_SESSION['dname'];
      $query = "INSERT INTO pages (menulabel, content, dname) VALUES (?, ?, ?)";
  
      $statement = $databaseConnection-&gt;prepare($query);
      $statement-&gt;bind_param('sss', $menulabel, $content, $dname);
      $statement-&gt;execute();
      $statement-&gt;store_result();
  
      if ($statement-&gt;error)
      {
          die('Database query failed: ' . $statement-&gt;error);
      }
  
      $creationWasSuccessful = $statement-&gt;affected_rows == 1 ? true : false;
      if ($creationWasSuccessful)
      {
          header ("Location: index.php");
      }
      else
      {
          echo 'Failed';
      }
  }
  </code></pre>
  
  <p>The mysql table:</p>
  
  <pre><code>     $query_pages = "CREATE TABLE IF NOT EXISTS pages (id INT NOT NULL AUTO_INCREMENT, menulabel VARCHAR(50), content TEXT, dname VARCHAR(50), PRIMARY KEY (id))";
      $databaseConnection-&gt;query($query_pages);
  </code></pre>
  
  <p>The php successfully adds the 'menulabel' and 'content' to the table and continues leaving the 'dname' NULL.
  <br> Please help, this is my first time with php.</p>