note 13575 deleted from features.http-auth by irc-html

From: Date: Sat, 19 Jan 2002 20:29:14 +0000
Subject: note 13575 deleted from features.http-auth by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25318@lists.php.net to get a copy of this message
I've used the small script from tigran@freenet.am posted 19-May-2000 02:31, it's pretty fine, authetification and logout using headers, but I've found a small error: The login on the database must be set to 0 when the user is not authorized because if you click "cancel" on the password dialog the browser (at least IE5.5) thinks that the previous user is entering and sets both $PHP_AUTH_USER and $PHP_AUTH_PW to the old values, and the next time you try to enter it doesn't ask for authentification Using the same code as him/her the function auth() will be: function auth () { global $PHP_AUTH_USER, $PHP_AUTH_PW; Header("WWW-Authenticate: Basic realm=\"ArmFN public site\""); Header("HTTP/1.0 401 Unauthorized"); mysql_connect("localhost","train","") or die("Unable to connect to SQL server"); mysql_select_db( "train") or die( "Unable to select database"); mysql_query("update users set login=0 where id='$PHP_AUTH_USER' and pasw='$PHP_AUTH_PW'") or die("k"); echo "You have to authentificate yourself first \n"; exit; }

« previous php.notes (#25318) next »