What are best practices for securely handling passwords, such as using MD5 encryption, in PHP scripts?

Storing passwords securely is crucial to protect user data. Instead of using MD5 encryption, it is recommended to use stronger hashing algorithms like bcrypt or Argon2. These algorithms are specifically designed for password hashing and are more secure than MD5.

// Hashing a password using bcrypt
$password = 'mySecurePassword';
$hashedPassword = password_hash($password, PASSWORD_BCRYPT);

// Verifying a password
$enteredPassword = 'mySecurePassword';
if (password_verify($enteredPassword, $hashedPassword)) {
    echo 'Password is correct';
} else {
    echo 'Password is incorrect';
}