title: Keep value in form after submitting PHP
body: <p>I'm calling these functions from a controller to get the form and the values from the form. My question is, how can I keep the values in the form after a submit fails? I've tried something like this:</p>
  
  <pre><code> &lt;input type="text" name="myField1" value="&lt;?php echo isset($_POST['myField1']) ? $_POST['myField1'] : '' ?&gt;" /&gt;
  </code></pre>
  
  <p>but can't get it to work.</p>
  
  <pre><code>private $m_username = 'username';
  private $m_password = 'password';
  private $m_registerButton = 'registerButton';
  
  public function RegisterUserBox(){
      return
      '&lt;form method="post"&gt;
              &lt;fieldset&gt;
                  Username: &lt;input type="text" name="'.$this-&gt;m_username.'" /&gt;
                  Password: &lt;input type="password" name="'.$this-&gt;m_password.'" /&gt;
                  &lt;input type="submit" value="Register" name="'.$this-&gt;m_registerButton.'"/&gt;
              &lt;/fieldset&gt;
       &lt;/form&gt;';
  
  }
  
  public function GetUsername(){
      if(isset($_POST[$this-&gt;m_username])){
          return $_POST[$this-&gt;m_username];
      }
  }
  
  public function GetPassword(){
      if (isset($_POST[$this-&gt;m_password])){
          return $_POST[$this-&gt;m_password];
      }
  }
  
  public function TriedToRegister(){
      if (isset($_POST[$this-&gt;m_registerButton])){
          return true;
      }
      return false;
  }
  </code></pre>