What are the potential risks of not using HTTPS for password transmission in PHP applications?

When passwords are transmitted over HTTP instead of HTTPS in PHP applications, they are sent in plain text and can be easily intercepted by malicious actors. This puts user data at risk of being stolen and used for unauthorized access to accounts. To mitigate this risk, it is essential to use HTTPS to encrypt the communication between the client and server.

// Ensure that the PHP application uses HTTPS for password transmission
if ($_SERVER['HTTPS'] !== 'on') {
    header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    exit();
}