I'm new to Classes. For a project to improve my skills I'm stuck.
This project is a registration in which:
- form data is validated
- some variable from the form are encrypted
- some variables from the form are hashed
It is getting the Class for hashing to load and work that is a problem. Here is my code so far:
if (isset ($_POST['submit'])) {
include ('include/Validate.php');
$newUser = new Validate();
if ($newUser->isValidated()){
include ('include/Encrypt.php');
$newEncrypt = new Encrypt();
if($newEncrypt->isEncryptedOk()){
include ('include/Hash.php');
$newHash = new HashVariables(); //error occurs here
if($newHash->isHashOk()){
echo 'This is good';die();
} else {
echo 'This is bad';die();
}
} else {
//NOT Encrypted ok, generate output
$output = " <div class=\"error\"><h1 id=\"encryptError\">Program halted. Encryption failure.</h1></div>";
}
} else {
.....what to do if $_POST not set
This is the error I get:
Call to private HashVariables::__construct() from invalid context in ..... and it pertains to Line 14 above.
Am I somehow breaking rules by having Classes nested in if's within if's?
I've googled the above error message and not found anything helpful.
In case this helps, here is the top of the HashVariables Class to the end of __construct():
class HashVariables {
private $password;
//private $passwordsalt_hash;
private $salt;
private function __construct(){
$this->_errors = array();
$this->password = $this->verifyPassword($_POST['password1']);
$this->salt = $this->verifiySalt($_POST['salt']);
}
Thanks for taking time to read this.
D