$data = $_POST;
if (isset($data['change'])) {
$errors = array();
$user = R::findOne('users', 'login = ?', array($_SESSION['logged_user']->login));
if( $user ){
if( $data['password'] == '' )
{
$errors[] = 'Введите пароль!';
}
if( $data['new_password'] == '' )
{
$errors[] = 'Введите новый пароль!';
}
if( $data['conf_password'] == '' )
{
$errors[] = 'Повторите пароль!';
}
if( $data['new_password'] != $data['conf_password'] )
{
$errors[] = 'Пароли не совпадают!';
}
if( password_verify(password_hash($data['password'], PASSWORD_DEFAULT), $user->password))
{
if( empty($errors) )
{
$user->password = password_hash($data['new_password'], PASSWORD_DEFAULT);
R::store($user);
echo '<div class="success"><p>Пароль изменён!</p></div>';
}
else
{
echo '<div class="errors">'.array_shift($errors).'</div>';
}
}
else
{
$errors[] = 'Неверный пароль!';
}
}
}
?>
<section class="section-catalog">
<div class="profile-content">
<div class="section-content">
<form action="change_password.php" method="POST" class="profile-password">
<p>
<p><strong>Текущий пароль</strong>:</p>
<input type="password" name="old_password" value="">
</p>
<p>
<p><strong>Новый пароль</strong>:</p>
<input type="password" name="new_password" value="">
</p>
<p>
<p><strong>Повторите пароль</strong>:</p>
<input type="password" name="conf_password" value="">
</p>
<p>
<button type="submit" name="change">Изменить</button>
</p>
</form>
</div>
</div>
$user = R::findOne('users', 'login = ?', array($_SESSION['logged_user']->login));
var_dump($user);