Advertisement
Guest User

Untitled

a guest
Feb 11th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. $option = ['cost' => 12];
  2. $password = password_hash($_currentpassword, PASSWORD_BCRYPT, $option);
  3.  
  4. $selectpasswordsql = "SELECT `password` FROM `auth` WHERE username=?";
  5. $selectpasswordstmt = $conn->prepare($selectpasswordsql);
  6. $selectpasswordstmt->execute(array($_SESSION['account']['username']));
  7. $selectpasswordresults = $selectpasswordstmt->fetch(PDO::FETCH_ASSOC);
  8.  
  9. $databasepass = $selectpasswordresults['password'];
  10. if(password_verify($_currentpassword,$databasepass)){
  11. if(empty($passmsgs)){
  12. $updatepasssql = "UPDATE `auth` SET
  13. `password`=?
  14. WHERE username=?
  15. ";
  16. $updatepassstmt = $conn->prepare($updatepasssql);
  17. $updatepassstmt->execute(array(password_hash($password, $_SESSION['account']['username']));
  18. if($updatepassstmt){
  19. array_push($passmsgs, 'Successfully updating your password!');
  20. } else {
  21. array_push($passmsgs, 'There was a problem executing your command!');
  22. }
  23. }
  24. } else {
  25. array_push($passmsgs, 'Your current password is wrong!');
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement