What are the potential risks of storing passwords in plain text within PHP files on a web server?

Storing passwords in plain text within PHP files on a web server is highly insecure because anyone with access to the server can easily view the passwords. This can lead to unauthorized access to sensitive data and potential security breaches. To solve this issue, passwords should be securely hashed before storing them in a database.

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

// Storing the hashed password in the database
// Example SQL query: INSERT INTO users (username, password) VALUES ('john_doe', '$hashed_password');