DeveloperBreeze

Server Variables Development Tutorials, Guides & Insights

Unlock 2+ expert-curated server variables tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your server variables skills on DeveloperBreeze.

Basic Authentication

Code January 26, 2024
php

$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
if ($username == 'admin' && $password == 'secret') {
    echo 'Authentication successful.';
} else {
    header('WWW-Authenticate: Basic realm="Restricted Area"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Authentication failed.';
    exit;
}

Get Current URL

Code January 26, 2024
php

No preview available for this content.