title: Undefined Index for $_POST (noob question!)
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index">PHP: “Notice: Undefined variable”  and “Notice: Undefined index”</a>  </p>
  </blockquote>
  
  
  
  <p>I am just learning PHP and I keep getting an Undefined Index error. The book I'm learning from has an HTML form and a PHP page that processes the form, using the following format:</p>
  
  <pre><code>&lt;!-- The form fields are all set up something like this --&gt;
  &lt;input type="text" id="howlong" name="howlong" /&gt;&lt;br /&gt;
  
  // The PHP starts with one line like this for each of the form fields in the HTML
  $how_long = $_POST ['howlong'];
  
  // And there is one line for each one like this to output the form data: 
  echo ' and were gone for ' . $how_long . '&lt;br /&gt;';
  </code></pre>
  
  <p>The example I'm working with has about 12 form fields.</p>
  
  <p>What's odd is that not all of the variables throw this error, but I can't see a pattern to it.</p>
  
  <p>I've checked that all HTML fieldnames match up with the PHP $_POST variable name I entered, and I've made certain that when I fill out the form and submit it that all fields are filled in with something.  Interestingly, the completed code that can be downloaded for the book also throws this error.</p>
  
  <p>I realize this code may not reflect best practices, it's from the first chapter of the book and obviously I am a noob :)</p>
  
  <p>In case it makes a difference, I am using PHP 5.3.5 on XAMPP 1.7.4 with Windows 7 Home Premium.</p>