What are the best practices for securely handling user login credentials, such as passwords stored in md5 format, in PHP applications?

When storing user login credentials, it is important to securely hash passwords using a strong hashing algorithm like bcrypt instead of md5. This helps protect user passwords in case of a data breach. Additionally, it is recommended to use prepared statements to prevent SQL injection attacks when interacting with the database.

// Hashing user password using bcrypt
$hashed_password = password_hash($password, PASSWORD_BCRYPT);

// Verifying hashed password
if (password_verify($password, $hashed_password)) {
    // Password is correct
} else {
    // Password is incorrect
}