What are the advantages and disadvantages of using hashing algorithms like MD5 or SHA1 in PHP login scripts for password storage and validation?

Using hashing algorithms like MD5 or SHA1 for password storage in PHP login scripts has some advantages, such as simplicity and ease of implementation. However, these algorithms are no longer considered secure due to their vulnerability to brute force attacks and collision vulnerabilities. It is recommended to use stronger hashing algorithms like bcrypt or Argon2 for password storage to ensure better security.

// Example of using bcrypt for password hashing in PHP
$password = "password123";
$hashed_password = password_hash($password, PASSWORD_BCRYPT);

// Example of verifying hashed password
$entered_password = "password123";
if (password_verify($entered_password, $hashed_password)) {
    echo "Password is correct";
} else {
    echo "Password is incorrect";
}