What are the best practices for securely storing passwords in a PHP application, considering the use of MD5 and SHA1 hashes?

To securely store passwords in a PHP application, it is recommended to use a strong hashing algorithm like bcrypt or Argon2 instead of MD5 or SHA1, which are considered weak and vulnerable to attacks. These algorithms provide better security by incorporating salt and multiple iterations to protect against brute force attacks.

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

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