What are common pitfalls when implementing password protection in PHP?

One common pitfall when implementing password protection in PHP is storing passwords in plain text, which can lead to security vulnerabilities if the database is compromised. To solve this, passwords should be securely hashed using a strong hashing algorithm like bcrypt before storing them in the database.

// Hashing a password before storing it in the database
$password = "password123";
$hashed_password = password_hash($password, PASSWORD_DEFAULT);

// Verifying a password
$entered_password = "password123";
if (password_verify($entered_password, $hashed_password)) {
    echo "Password is correct!";
} else {
    echo "Password is incorrect!";
}