Notice: Undefined index: name in C:\xampp\htdocs\php\second.php on line 2
<p>I am begineer in php . as this code i have been practising from tutorialspoint.com. in the site this code has produced the actual result but while running in my localhost it says undefined index : name in C:\xampp\htdocs\php\second.php on line 2.     </p>

<pre><code>&lt;?php
if( $_POST["name"] || $_POST["age"] ) {
if (preg_match("/[^A-Za-z'-]/",$_POST['name'] )) {
die ("invalid name and name should be alpha");
}
echo "Welcome ". $_POST['name']. "&lt;br /&gt;";
echo "You are ". $_POST['age']. " years old.";
exit();
}
?&gt;
&lt;!------------Form-----------------&gt;
&lt;html&gt;
&lt;body&gt;
&lt;form action = "&lt;?php $_PHP_SELF ?&gt;" method = "POST"&gt;
Name: &lt;input type = "text" name = "name" /&gt;
Age: &lt;input type = "text" name = "age" /&gt;
&lt;input type = "submit" /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>