- Code: Select all
namespace Lib\Form;
class verifyPassword extends \Lib\Form {
public $_error;
private $_data;
private $_test;
function __construct($data=null, $multiPasswords=false, $multiData=null) {
$this->_data = $data;
if(empty($data) && !$multiPasswords) {
$this->_result(ERROR_FORM_EMPTY_PASSWORD);
}
if(empty($data) && $multiPasswords) {
$this->_result(ERROR_FORM_EMPTY_PASSWORD2);
} elseif($multiPasswords && $data != $multiData) {
$this->_result(ERROR_FORM_NOMATCH_PASSWORD);
}
}
private function _result($error) {
if(!empty($error)) {
$this->_error = $error;
} else {
$this->_error = false;
}
}
public function isVerified() {
return empty($this->_error) ? true : false;
}
public function getData($testerror) {
if(empty($testerror)) {
return fancySuperSecretHashPasswordThing();
} else {
return false;
}
}
}
File 2:
- Code: Select all
echo $validator->getData($validator->_error);
Issue:
If I put this code:
- Code: Select all
echo "__" . $testerror . "__";
at the top of the getData function it will echo as expected but if i put the same piece of code right after the if-statement it wont echo it and if i echo something not using the $this->_error variable it does echo.
Im very confused to why this is happening. Its like $testerror is being reset somewhere but thats impossible right ?
EDIT: I find that it works if i use SESSION variables instead of a normal variable for $this->_error but is there any other way of doing this that doesnt involve SESSION variables ?

