What are the potential security risks of storing passwords as plain text in a PHP database?

Storing passwords as plain text in a PHP database poses a significant security risk because if the database is compromised, all user passwords will be exposed. To mitigate this risk, passwords should be securely hashed before storing them in the database. This ensures that even if the database is breached, the actual passwords cannot be easily retrieved.

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