Добавлена возможность перехешировать пароль по запросу.

This commit is contained in:
Igor Barkov [iwork] 2018-03-06 14:34:57 +02:00
parent 9196512713
commit c1bafc1f77
2 changed files with 7 additions and 6 deletions

View File

@ -63,13 +63,13 @@ $username_upd = filter_input(INPUT_POST, 'username_upd', FILTER_SANITIZE_SPECIAL
$password_upd = filter_input(INPUT_POST, 'password_upd');
if ($username_upd && $password_upd) {
$data = db::c()->query('SELECT `id`, `login` ,`pass`, `room`, `block` FROM `users` WHERE `login` = "?s" AND `pass` = "?s"', $username, md5($password))->fetch_assoc();
if ($data) {
$hashed_password = password_hash($password_upd, PASSWORD_DEFAULT);
db::c()->query('UPDATE `users` SET `pass` = "?s" WHERE `login` = "?s"', $username_upd, $hashed_password);
$data = db::c()->query('SELECT `id`, `login` ,`pass`, `room`, `block` FROM `users` WHERE `login` = "?s" AND `pass` = "?s"', $username_upd, md5($password_upd))->fetch_assoc();
if ($data['id']) {
db::c()->query('UPDATE `users` SET `pass` = "?s" WHERE `login` = "?s"', $username_upd, password_hash($password_upd, PASSWORD_DEFAULT));
echo '<span class="greenalert">Пароль обновлён!</span>';
}
} else {
echo '<span class="redalert">Ошибка!</span>';
}
}
?>

View File

@ -17,13 +17,14 @@
<input type=submit value='Отправить'>
</form>
<div style="background: seashell; border-radius: 5px; margin: 10px; padding: 10px;">
<div style="background: seashell; border-radius: 5px; margin-top: 10px; padding: 10px; display: inline-block;">
<form method="post" action="enter.php">
Обновление пароля<br>
<input name='username_upd' placeholder='Логин'>
<input name='password_upd' placeholder='Пароль' type="password">
<input type=submit value='Отправить'>
</form>
<p>Если не пускает внутрь, обнови пароль!</p>
</div>
<ul class="menu">