What are some common pitfalls when storing passwords in PHP?

One common pitfall when storing passwords in PHP is storing them in plaintext, which can lead to security vulnerabilities if the database is compromised. To solve this issue, passwords should be hashed using a secure hashing algorithm like bcrypt before storing them in the database.

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

// Storing the hashed password in the database
// $hashed_password should be stored in the database