What is the difference between HTTP and HTTPS headers in PHP authentication on SSL pages?

When authenticating users on SSL pages in PHP, it is important to use HTTPS headers instead of HTTP headers to ensure secure communication. HTTPS headers provide encrypted data transmission, while HTTP headers do not. This helps protect sensitive information such as login credentials from being intercepted by malicious actors.

// Set HTTPS headers for secure authentication on SSL pages
if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') {
    header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    exit();
}