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:
<input type="text" name="myField1" value="<?php echo isset($_POST['myField1']) ? $_POST['myField1'] : '' ?>" />
but can't get it to work.
private $m_username = 'username';
private $m_password = 'password';
private $m_registerButton = 'registerButton';
public function RegisterUserBox(){
return
'<form method="post">
<fieldset>
Username: <input type="text" name="'.$this->m_username.'" />
Password: <input type="password" name="'.$this->m_password.'" />
<input type="submit" value="Register" name="'.$this->m_registerButton.'"/>
</fieldset>
</form>';
}
public function GetUsername(){
if(isset($_POST[$this->m_username])){
return $_POST[$this->m_username];
}
}
public function GetPassword(){
if (isset($_POST[$this->m_password])){
return $_POST[$this->m_password];
}
}
public function TriedToRegister(){
if (isset($_POST[$this->m_registerButton])){
return true;
}
return false;
}