title: PHP form validation, keep field values after refresh
body: <p>I am currently making a registration/validation script for a website and stumbled across a question.</p>
  
  <p>I am using all PHP to validate and using if statements to echo the array of errors.</p>
  
  <p><b>My question is:</b> How can I keep the user's input values in the form after refresh? Must I learn AJAX?</p>
  
  <ul>
  <li>NOTE: The file I am regarding is <code>register.php</code>, which sends data to the same page (<code>action = ""</code>). And <code>form_handle.php</code> is the actual validation script included at the very top/beginning of <code>register.php</code></li>
  </ul>
  
  <p><code>form_handle.php</code>CODE:</p>
  
  <pre><code>    $errors = array();
  
  if( empty($safe_fname) || 
      empty($safe_lname) || 
      empty($safe_email) || 
      empty($safe_email_again) || 
      empty($safe_password) )
          { 
          $errors = '&lt;p&gt;One or more fields left empty'; 
          }
  elseif( strlen($safe_password) &lt; 6)
      { 
      $errors = '&lt;p&gt;Password must be atleast 6 charcters long.&lt;/p&gt;'; 
      }
  
  elseif($safe_email != $safe_email_again)
      { 
      $errors = '&lt;p&gt;E-mails do not match.&lt;/p&gt;'; 
      } 
  </code></pre>
  
  <p><code>The form</code> CODE:</p>
  
  <pre><code>       &lt;h2&gt;Sign up Today!&lt;/h2&gt;
            &lt;form method="post" action=""&gt;
                     &lt;span class="p" id="p1"&gt;&lt;/span&gt;&lt;br/&gt; 
            &lt;input name="first_name" id="first" class="register_form cap" type="text" placeholder="First Name" /&gt;
                &lt;br/&gt;&lt;span class="p" id="p2"&gt;&lt;/span&gt;&lt;br/&gt; 
        &lt;input name="last_name" id="second" class="register_form cap" type="text" placeholder="Last Name" /&gt;
            &lt;br/&gt;&lt;span class="p" id="p3"&gt;&lt;/span&gt;&lt;br/&gt; 
        &lt;input name="email" id="third" class="register_form" type="text" placeholder="E-mail" /&gt;
            &lt;br/&gt;&lt;span class="p" id="p4"&gt;&lt;/span&gt;&lt;br/&gt; 
        &lt;input name="email_again" id="fourth" class="register_form" type="text" placeholder="Re-enter E-mail" /&gt;
            &lt;br/&gt;&lt;span class="p" id="p5"&gt;&lt;/span&gt;&lt;br/&gt; 
        &lt;input name="password" type="password" class="register_form" placeholder="Password" /&gt;
            &lt;br/&gt;&lt;span class="p" id="p1"&gt;&lt;/span&gt;&lt;br/&gt;   
        &lt;input name="submit" id="fifth" class="register_form" type="submit" value="Create!" /&gt;
  
        &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>