title: Unable to insert data into mysql database using php form
body: <p>I am trying to learn some PHP using the book titled <em>PHP for Absolute Beginners</em>. I am trying to implement some blog design code given in the book using WAMP and editplus. When I try to insert the data using PHP form, all I get is NULL values in the database table. Here is a piece of code for inserting values into the DB. </p>
  
  <pre><code>&lt;?php
  if($_SERVER['REQUEST_METHOD']=='POST'
  &amp;&amp; $_POST['submit']=='Save Entry'
  &amp;&amp; !empty($_POST['title'])
  &amp;&amp; !empty($_POST['entry']))
  {
  // Include database credentials and connect to the database
  include_once 'db.inc.php';
  $db = new PDO(DB_INFO, DB_USER, DB_PASS);
  
  // Save the entry into the database
  $sql = "INSERT INTO entries (title, entry) VALUES (?, ?)";
  $stmt = $db-&gt;prepare($sql);
  $stmt-&gt;execute(array($title, $entry));
  $stmt-&gt;closeCursor();
  
  // Get the ID of the entry we just saved
  $id_obj = $db-&gt;query("SELECT LAST_INSERT_ID()");
  $id = $id_obj-&gt;fetch();
  $id_obj-&gt;closeCursor();
  
  // Send the user to the new entry
  header('Location: ../admin.php?id='.$id[0]);
  exit;
  }
  // If both conditions aren't met, sends the user back to the main page
  else
  {
  header('Location: ../admin.php');
  exit;
  }
  ?&gt;
  </code></pre>
  
  <p>When I check the apache error log I see this:</p>
  
  <pre><code>[Sun May 27 19:21:24 2012] [error] [client 127.0.0.1] PHP Notice:  Undefined 
  variable: title in C:\\wamp\\www\\examples\\simple_blog\\inc\\update.inc.php
  on line 14, referer: http://localhost/examples/simple_blog/admin.php?id=8
  [Sun May 27 19:21:24 2012] [error] [client 127.0.0.1] PHP Stack trace:, referer: 
  http://localhost/examples/simple_blog/admin.php?id=8
  [Sun May 27 19:21:24 2012] [error] [client 127.0.0.1] PHP   1. {main}() 
  C:\\wamp\\www\\examples\\simple_blog\\inc\\update.inc.php:0, referer:    
  http://localhost/examples/simple_blog/admin.php?id=8
  [Sun May 27 19:21:24 2012] [error] [client 127.0.0.1] PHP Notice:  Undefined 
  variable: entry in C:\\wamp\\www\\examples\\simple_blog\\inc\\update.inc.php 
  on line 14, referer: http://localhost/examples/simple_blog/admin.php?id=8
  [Sun May 27 19:21:24 2012] [error] [client 127.0.0.1] PHP Stack trace:, referer: 
  http://localhost/examples/simple_blog/admin.php?id=8
  [Sun May 27 19:21:24 2012] [error] [client 127.0.0.1] PHP   1. {main}() 
  C:\\wamp\\www\\examples\\simple_blog\\inc\\update.inc.php:0, referer: 
  http://localhost/examples/simple_blog/admin.php?id=8
  </code></pre>
  
  <p>I don't know what these errors are. Please help me.</p>