if (password_verify($password, $result['password']) && (int) $result['blocked'] !== 1) { print_r($result); $user = new User($result['username'], $result['password'], $result['administrator']); $_SESSION["usertype"] = $user->getUserPrivilege(); $_SESSION["username"] = $user->getUsername(); $_SESSION["ip"] = $user->getRealIpAddr(); header("location:frontend/index.php"); exit; } elseif ((int) $result['blocked'] === 1) { header("location:blocked.html"); exit; } else { //******wrap it in a function********// if ($record) { $counter = (int) $record['login_counter']; $loginCounter = $mainController->updateLoginCounter($ip, $counter); } else { $mainController->setLoginRecord($ip); } if ($loginCounter >= 5) { header("location:blocked.html"); } //************************************// session_write_close(); http_response_code(401); header("location:login.php"); exit; } } else { //*********** wrap it in a function ********// if ($record) {