I currently have a problem with the following php code:
if ($result['username'] == $_POST["name"]) {
$bcrypt = new Bcrypt(10);
$password = $_POST["password"];
$hashdb = $result['password'];
$hash = $bcrypt->hash($password);
$isGood = $bcrypt->verify($password, $hashdb);
if ($isGood == 1) {
if($result['active'] == 1) {
$_SESSION["login"] = $result['firstname']." ".$result['lastname'];
$_SESSION["functionlevel"] = $result['functionlevel'];
header("location:startpagina.php");
} else {
echo 'Account blocked or not activated';
}
} else {
echo 'Password not correct';
}
} else {
echo 'Username not correct';
}
I am using the Andrew Moore bcrypt class for hashing and verifying the passwords.
For some reason my if statement seems to fail and suddenly stops after the second if statement. If this one fails it shows the password not correct option. But if it is true it does not continue to the third if.
I have tried different options in the second if like:
if ($isGood){
if ($isGood == true){
if ($isGood !== false){
if ($isGood !== 0){
But somehow none of these seem to continue if the statement is met.
It just shows the login page again instead of continuing to startpagina.php.
The login page worked fine without the bcrypt implementation and with just checking two md5 hashes against each other.
Can anybody help me trying to find the problem?