473,800 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.htaccess & .htpasswd

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


Jul 17 '05 #1
2 2655
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!
Jul 17 '05 #2
Hello Jay
If you're using PHP5, make sure you have the latest release.

Many thanks four your quick answer. I have to look with
version my webhoster are using!

Regards

Otto

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2971
by: Lothar Bayer | last post by:
Hallo, I want zu install a security-path with .htaccess and .htpasswd on my privat local machine (for test-reason) I succeeded with a .htaccess and Error 404-adressing a special Error-page with menu. SSI and PHP are accessible.. My Apache is installed in path C:\Apache2\ My homepage is in D:\Daten\htdocs\effektiv\familienzentrum.com\ and is named http://fzt.local/
3
5109
by: starlightjen | last post by:
Hello, I'm trying to use php to update my htpasswd file. I have my permissions on .htpasswd set to 777, so it should be wide open. From the command line (when logged into the server as "nobody", my server's web user) I can get the htpasswd.exe to run without a problem, but when passed through my php exec() function the .htpasswd file does not change. I'm not getting any errors, but I'm not getting any action either.
0
1876
by: Ludwig77 | last post by:
I'm trying to password protect a directory on my web site. I'm using the password encryption generator located at http://resma.net/tutorials/htaccess.php# I can't seem to get my login to work. I get a authentication prompt screen when trying to access the directory, but it won't authenticate. I've noticed that every time I enter the same password into the encryption tool, it generates a different password. How can this be?
1
4900
by: nickyeng | last post by:
I have checked this info from apache website, and i confused with it. Procteing System files it said: To run a really tight ship, you'll want to stop users from setting up .htaccess files which can override security features you've configured. Here's one way to do it. In the server configuration file, put
1
2071
by: Nosferatum | last post by:
Is it possible to make a custom php-form to log in to a protected folder with .htaccess/htpasswd? (Just wonder if it's possible to avoid the ugly standard server popup- login form).
0
6557
by: Jankie | last post by:
Good morning everyone Am hopeful that someone can share me some advice as to the best .htaccess example for a site under development. When i use something like this: <Limit GET POST> order deny,allow deny from all allow from my ip
1
2541
by: paitoon | last post by:
Helle I have problem about .htaccess in my site. My purpose is i want to protect a folder name's IMAGES in my site then i put .htaccess into that folder. But instead of the IMAGES folder will be protected but i could not open my site at all.seems like it not only protect the IMAGES folder but it protects to open my site also. what should i do ? and what is the actually syntext to do this? I use this systext; AuthUserFile...
0
1522
by: adamjblakey | last post by:
Hi, I have a folder on my server which i want to protect. I though everything is setup fine and does protect the folder but also protects the public_html also even though the htaccess file is in a sub folder. AuthName "Restricted Area" AuthType Basic AuthUserFile /vhost/vhost6/s/d/o/.htpasswd AuthGroupFile /dev/null require valid-user
8
1786
by: Geoff Cox | last post by:
Hello Can anyone recommend software which I can run from my own PC which will create the encrypted password for the htpasswd file? I have come across Htpasswd Generator which does the job but wondered if there is any software which costs less (£35).... Cheers
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10275
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.