• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 539
  • Last Modified:

PHP basic authentication set up

Hello, I would like to set up PHP and Apache configuration for PHP basic authentication. What do I need to configure it? Version php 4.4.7, Apache 1.3.37, MySQL 4.0.27-standard.

Best Regards, portal123
  • 2
2 Solutions
some nice step by step how to is here, it explains every little thing all the way
portal123Author Commented:
Thank, dr_dedo. but I prefer to use $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] without session

and generate query from a mysql table that contains user id and password. comparing $_POST variables with user id and password at the query.  I made the following code and it works well at a previous server, but I've changed a new server and it does not work on it.

So, I guess probably some setting problems on Apache and PHP.

Do I need to set anything on PHP and Apache when I use $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] on them ??
The method given in the article pointed out by dr. dedo exemplifies the process of implementing the authentication process as part of the application itself via html forms.

On the other hand, if you are using the PHP module (not CGI), you may implement HTTP-protocol authentication. The difference is that the browser will pop-up an username/password window and the script will be able to handle the authentication itself. A complete example of this may be found in:

Finally, authentication may be handled entirely by the web server (Apache). The documentation about how to do this is here:
Notice that when authentication is handle this way, you may use one of several apache modules to handle the username/password database, such as mod_auth_db for using a database.

One more note: It is recommended to use digest authentication (as opposed to basic authentication) because in this mode the password does not traverse the network.
portal123Author Commented:
I made a simple mistake on $_SERVER['PHP_AUTH_PW']. I wrote not $_SERVER['PHP_AUTH_PW'] but $_SERVER['PHP_AUTH_PWD'] .

Anyway, thanks both guys....
for($i=1; $i<=100; $i++){
echo "THANKS";
echo "<BR />";
Best Regards, portal123

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now