title: Error when trying to retain value entered in PHP form text field after browser refresh
body: <p>I am trying run a small PHP script. I get an error when I try to run this small PHP line:
  &lt;<strong>?PHP print $firstname ;</strong> ?>  within the html code. According to my tutorial guide this line in the value element should ensure that I keep any input text  entered into the text fields even after I refresh the browser, but it does not! the following error message occurs:</p>
  
  <blockquote>
    <p>Notice: Undefined variable: surname in C:\wamp\www\pages\basicForm.php
    on line 27 Call Stack #TimeMemoryFunctionLocation 10.0007366504{main}(
    )..\basicForm.php:0 " NAME="surname"></p>
  </blockquote>
  
  <p>Why?</p>
  
  <p>and the code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
          &lt;?PHP
          if (!empty($_POST)) {
              $firstname = $_POST['firstname'];
              $surname = $_POST['surname'];
              print($firstname);
              print($surname);
          }
          else {
  
          } print( 'welcomes');
      ?&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;Form name ="form1" Method ="POST" Action ="basicForm.php"&gt;
      &lt;label&gt;
  
  
      &lt;INPUT TYPE = 'TEXT' Name ='firstname' VALUE="&lt;?PHP print $firstname ; ?&gt;"&gt;
      &lt;/label&gt;
  
      &lt;p&gt;
          &lt;label&gt;
              &lt;INPUT TYPE="TEXT" VALUE="&lt;?PHP print($surname); ?&gt;" NAME="surname"&gt;
          &lt;/label&gt;
  
      &lt;p&gt;
          &lt;Input Type = "Submit" Name = "Submit1" Value = "Login"&gt;
  &lt;/FORM&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>