What are the potential security risks of sending passwords in plain text via POST in PHP login forms?

Sending passwords in plain text via POST in PHP login forms poses a significant security risk as the data can be intercepted and read by malicious actors. To mitigate this risk, passwords should be securely hashed before being sent over the network. This ensures that even if the data is intercepted, the actual password remains hidden.

// Hash the password before sending it via POST
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);

// Use the hashed password for authentication
// Example code for checking password:
if (password_verify($_POST['password'], $hashed_password)) {
    // Password is correct
} else {
    // Password is incorrect
}