prepare($sql); $stmt->bindValue(':new_password', password_hash($_POST['new_password'], PASSWORD_DEFAULT)); $stmt->bindValue(':user_id', $_SESSION['user_id']); $stmt->execute(); ?>
password = bcrypt('new_password'); $user->save(); ?>In this example, we're using the Laravel framework, which provides a convenient `Auth` facade for authentication-related tasks. We get the currently logged-in user using the `user()` method, then update their password using the `bcrypt()` function, which generates a secure hash of the new password. Finally, we save the changes to the database using the `save()` method on the user model. Package library: In the first example, we're using plain PHP and PDO to connect to the database and prepare the SQL statement. In the second example, we're using the Laravel framework, which includes built-in authentication features and uses the `bcrypt()` function for password hashing.