Connecting Tech Pros Worldwide Forums | Help | Site Map

.htaccess & .htpasswd

Otto
Guest
 
Posts: n/a
#1: Jul 17 '05
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.

Regards

Otto





Senator Jay Billington Bulworth
Guest
 
Posts: n/a
#2: Jul 17 '05

re: .htaccess & .htpasswd


Otto <ohaldi@freesurf.ch> wrote in news:VA.00000301.002e4a76@freesurf.ch:
[color=blue]
> 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.[/color]

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=29132

If you're using PHP5, make sure you have the latest release.

hth


--

Bulworth : PHP/MySQL/Unix | Email : str_rot13('f@fung.arg'); Web :
shaunc.com
--------------------------
|--------------------------------------------------
<http://www.phplabs.com/> | PHP scripts and thousands of webmaster
resources!
Otto
Guest
 
Posts: n/a
#3: Jul 17 '05

re: .htaccess & .htpasswd


Hello Jay
[color=blue]
> If you're using PHP5, make sure you have the latest release.
>[/color]
Many thanks four your quick answer. I have to look with
version my webhoster are using!

Regards

Otto

Closed Thread