.htaccess Username - extact it in PHP?

S

(Shovel)

Guest
I'm sure this must be doable, but I can't think of the right terminology to look up the type of username to PHP documentation.

It's the type you define in a unix .htaccess file and you get a dialog box appear asking you to log in when you try to access a certain folder.

I just want to get the username that the person logs in with so I can use it on the page :)

Thank you :D
 
J

Jonty

Guest
Hi Ben

I think what you are after two predefined, global variables. These are $_SERVER["PHP_AUTH_USER"] to retrieve the username field of a HTTP login request, and, just for the sake of thoroughness, $_SERVER["PHP_AUTH_PW"] to retrieve the password field.

Hope this helps
 
J

Jonty

Guest
Sorry for replying twice, but edited posts are easy to overlook if you've already read them. With regards your question, this whole area is broadly termed 'Apache HTTP Authentication', with the two variables above being mentioned in this page of the PHP manual. I believe SitePoint also discuss this in their Apache HTTP Authentication article (which uses the slightly older syntax of $PHP_AUTH_AUTH / $PHP_AUTH_PW).

Kind Regards
 
S

(Shovel)

Guest
w00t :) Thank you Jonty :D

It's for a small project - a website for my friends band. I want to give him PHP news updating but I don't want to take the time to implement a secure user system, so using HTTP Auth seems like the quick and effective way through :D

EDIT:// thinking about it, it's the same website that you poked the CSS margins for :)
 
J

Jonty

Guest
Your welcome :D Just let me know if you need any further assistance :)

Kind Regards
 
W

wyrd_fish

Guest
I already have a error 403 bit in my htaccess file...

how odd???
 
O

old.Kez

Guest
Er, no.

403 is forbidden directory.
401 is auth failure.

You want:

ErrorDocument 401 /whatever.ext
 

Users who are viewing this thread

Similar threads

S
Replies
5
Views
735
L_Plates
L
T
Replies
3
Views
556
TheJkWhoSaysNi
T
S
Replies
2
Views
541
wyrd_fish
W
W
Replies
8
Views
1K
wyrd_fish
W
P
Replies
3
Views
729
wyrd_fish
W
Top Bottom