Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $option = ['cost' => 12];
- $password = password_hash($_currentpassword, PASSWORD_BCRYPT, $option);
- $selectpasswordsql = "SELECT `password` FROM `auth` WHERE username=?";
- $selectpasswordstmt = $conn->prepare($selectpasswordsql);
- $selectpasswordstmt->execute(array($_SESSION['account']['username']));
- $selectpasswordresults = $selectpasswordstmt->fetch(PDO::FETCH_ASSOC);
- $databasepass = $selectpasswordresults['password'];
- if(password_verify($_currentpassword,$databasepass)){
- if(empty($passmsgs)){
- $updatepasssql = "UPDATE `auth` SET
- `password`=?
- WHERE username=?
- ";
- $updatepassstmt = $conn->prepare($updatepasssql);
- $updatepassstmt->execute(array(password_hash($password, $_SESSION['account']['username']));
- if($updatepassstmt){
- array_push($passmsgs, 'Successfully updating your password!');
- } else {
- array_push($passmsgs, 'There was a problem executing your command!');
- }
- }
- } else {
- array_push($passmsgs, 'Your current password is wrong!');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement