HTTP AUTHENTICATION Solution

From: Date: Wed, 16 Jan 2002 06:24:14 +0000
Subject: HTTP AUTHENTICATION Solution
Groups: php.general 
Request: Send a blank email to php-general+get-80662@lists.php.net to get a copy of this message
Here is a solution I developed for the HTTP AUTHENTICATION on that buggy Internet Explorer. I want some feedbacks, improvements, Comments... Bharath (B. h. Loh.) bharath_b_lohray (at) yahoo.com Please correspond via email for my convinience and also on the News Group for the benifit of the Php Developers... =================== START OF SOURCE CODE [lohauthsol.php]=================== <?php //Username and password verification function //takes (username,password) returns TRUE/FALSE function verify($un,$pw) { //Verify against a database etc.... if ((($un=="bharath")&&($pw=="password1"))||(($un=="tom_dick_harrypotter")&&($p w=="password2"))) { $ok=TRUE; } else { $ok=FALSE; } return $ok; } //Procedure to display a standard error if login //fails function er($err) { echo "<html><head><title>$err</title></head><body bgcolor=\"#FFFFFF\" text=\"#000000\"><p><font face=\"Courier New, Courier, Terminal\" size=\"3\"><font size=\"5\">$err</font><br><br>Could not log you in. <a href=\"lohauthsol.php\">TRY AGAIN</a></font></p></body></html>"; } //Procedure to ask username and password by //HTTP AUTHENTICATION function ask() { header("WWW-Authenticate: Basic realm=\"1024x1024.net Administration\""); header("HTTP/1.0 401"); er("Unauthorized"); exit; } //BEGIN MAIN PROGRAMME if ((!isset($PHP_AUTH_USER))||(!verify($PHP_AUTH_USER,$PHP_AUTH_PW))) { ask(); } else { echo "OK"; exit; } ?> =================== END OF SOURCE CODE ===================

« previous php.general (#80662) next »