如您所见,我希望将伪代码与MySQL bd password_verif
的工作进行比较,但伪代码不起作用。
Router.php:
elseif ($_GET['action'] == 'connect') {
$connect = new ControllerLog();
$connect->connect($_POST['password'], $_POST['pseudo']);
}
控制器:
function connect($result)
{
$userManager = new \blog_ecrivain\Model\UserManager();
$passwordUser = $userManager->log();
$isPasswordOK = password_verify($result, $passwordUser['password']);
if (!$isPasswordOK)
{
$errormdp='Erreur : mot de passe incorrect !';
echo '<script>window.alert("'.$errormdp.'");</script>';
echo" <script>window.location='index.php?action=writepost';</script>";
}
else
{
$_SESSION['connect'] = true;
header ('location:./index.php?action=dashboard');
}
}
型号:
public function log()
{
$db = Manager::dbConnect();
$req = $db->prepare('SELECT id, pseudo, password FROM administration');
$result = $req->execute();
$result = $req->fetch();
return $result;
}