Otto <oh****@freesur f.ch> wrote in news:VA******** **********@free surf.ch:
Hello to all,
I have protected a directory with the help of .htaccess &
htpasswd.
I also read that I can get the login value in a php
variable.
Like this:
$user = $_SERVER['PHP_AUTH_USER'];
echo "User : ";
echo $user;
I did it, but nothing is displayed after the echo User!
I don't really know if it's the right way to get this
value.
Could somebody give me some help.
That is the correct way to determine the .htpasswd user's username. In
order for it to work, the script must be located somewhere inside of the
..htpasswd protected directory, and a valid authenticated user must be
logged in.
If this all sounds right, and it still isn't working, what is the setup
of your web server?
It looks like some early versions of PHP5 had a problem with $_SERVER
[PHP_AUTH_USER] :
http://bugs.php.net/bug.php?id=2913 2
If you're using PHP5, make sure you have the latest release.
hth
--
Bulworth : PHP/MySQL/Unix | Email : str_rot13('f@fu ng.arg'); Web :
shaunc.com
--------------------------
|--------------------------------------------------
<http://www.phplabs.com/> | PHP scripts and thousands of webmaster
resources!