Possible duplicate:
PHP: "Note: Undefined variable" and "Notice: Undefined index"
I am just learning PHP and I keep getting Undefined index error. The book I am studying has an HTML form and a PHP page that processes the form using the following format:
<input type="text" id="howlong" name="howlong" /><br />
// 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 . '<br />';
The example in which I work contains about 12 form fields.
What is strange is that not all variables throw this error, but I do not see a template in it.
I checked that all the HTML field names match the name of the PHP variable $ _POST that I entered, and I made sure that when I fill out the form and submit it, all the fields are filled with something. Interestingly, the completed code that can be downloaded for the book also causes this error.
, , , , noob:)
, , PHP 5.3.5 XAMPP 1.7.4 Windows 7 Home Premium.