title: How can I keep a value in a text input after a submit occurs?
body: <p>I want to validate a form to make sure a user writes in a name and last name.</p>
  
  <p>If a user writes in only his last name, the form should show again with an error message beside the last name field, but the name value should <strong>still</strong> be there.</p>
  
  <p>I don't know how to do this, hehe. I'm just a newbie PHP programmer.</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;form action="formprueba.php" method="get"&gt;
          &lt;dl&gt;
              &lt;dt&gt;Last Name:&lt;/dt&gt;
              &lt;dd&gt;&lt;input type="text" value="" name="name" /&gt;
                  &lt;?php if((isset($_GET['name'])) &amp;&amp; ($_GET['name'] == "")){
                      echo "Please write a correct name.";
                  }
                  ?&gt;
              &lt;/dd&gt;                
  
              &lt;dt&gt;Last Name:&lt;/dt&gt;
              &lt;dd&gt;&lt;input type="text" value="" name="lastname" /&gt;
                  &lt;?php if((isset($_GET['lastname'])) &amp;&amp; ($_GET['lastname'] == "")){
                      echo "Please write a correct last name.";
                  }
                  ?&gt;
              &lt;/dd&gt;
  
              &lt;br /&gt;                
              &lt;dt&gt;
                  &lt;input type="submit" value="enviar" /&gt;
              &lt;/dt&gt;
              &lt;input type="hidden" name="enviado" value="j"/&gt;
          &lt;/dl&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>Also, I'm sure this validation is horrible, if you have a couple of minutes, I'd be really grad if someone can show me a more efficient way to validate (without using third party addons).</p>
  
  <p>Thanks SO.</p>