HTTP user login

Problems with the Windows version of XAMPP, questions, comments, and anything related.

HTTP user login

Postby ippo » 21. August 2011 05:29

I have the following code which should prompt with a pop-window for user-authentication with HTTP. It should pop-up a window asking for username & password ,but it is not doing so.
I am clueless as this same code earlier worked in my same machine with same XAMPP setup. Only difference is I have reinstalled XAMPP in a different drive than earlier but in both cases it was different from my primary drive,so it should work this time too but it is not working !! Earlier my XAMPP was setup in the I drive this time in the H drive ( both are external hard disks) & don't tell me to reinstall XAMPP again in my primary C partition please.
I can't remember exactly what changes i did to those configuration files in my earlier attempt but I did made some change in httpd.conf and php.ini im my earlier attempt with the following code so that it worked then, but this time I can't manage to do this again!!
I present the code below -
Code: Select all
/* Program: Auth.php
 * Desc:    Program that prompts for a user name and
 *          password from the user using HTTP authentication.
 *          The program then tests tests whether the user
 *          name and password match a user name and password
 *          pair stored in a MySQL database.

 //Testing whether the user has been prompted for a user name
    header('WWW-Authenticate: Basic realm="secret section"');
    header('HTTP/1.0 401 Unauthorized');                 
    exit("This page requires authentication!");         

 // Testing the user name and password entered by the user
    $user_name = trim($_SERVER['PHP_AUTH_USER']);         
    $user_password = trim($_SERVER['PHP_AUTH_PW']);
    $connection = mysql_connect("localhost","root","ABCD")
               or die ("Couldn't connect to server.");   
    $db = mysql_select_db("UserAccount",$connection)
               or die ("Couldn't select database.");
    $sql = "SELECT user_name FROM Valid_User
                WHERE user_name = '$user_name'
                AND password = md5('$user_password')";
    $result = mysql_query($sql)
                  or die("Couldn't execute query.");     
    $num = mysql_num_rows($result);                     
    if ($num < 1)  // user name/password not found       
       exit("The User Name or password you entered
                    is not valid.<br>");
 // Web page content.                                   

Unfortunately it is not presenting the pop-up window ,instead it shows in the browser a error- "The User Name or password you entered is not valid."
Whereas I have created a file where I have created the following code-

Code: Select all
        $host = "localhost";
        $user = "root";
        $passwd = "ABCD";
        $database = "UserAccount";

Firstly, 'ABCD' is the password for MySQL prompt,root is the username, and "UserAccount" is the database created ,inside the database, I have created a "ValidUser" table and populated it with some valid data,It contains "user_name","user_password","join_date" as columns/fields with user_name being the primary key. The above program is called "Auth.php" & I have placed it in this directory -
I have also placed the "" (containing the necessary connection data) file and" file inside this same folder where the above" auth.php" is located.
I am using Apache Friends XAMPP (Basis Package) version 1.7.3 ,my OS is Windows XP and I have installed not in my primary drive which is C drive ,instead my XAMPP folder is located in H:\ drive.

My php.ini is located in H:\xampp\php\php.ini & my Apache config file is located in

I have tried to modify the php.ini file by removing the ; comment symbol in front of include_path directive,but it didn't help me remove the error I am getting
Initially it was like this-
; Windows: "\path1;\path2"
;include_path = ".;c:\includes"

But since my php.ini is not located in C drive,so I changed the above line to this-

; Windows: "\path1;\path2"
include_path = ".;H:\xampp\htdocs\ww\Projects\Procedural;H:\xampp \apache\include;I:\secret"
I place all php files in the above "ww" directory inside 'htdocs' folder and it used to run in browser,but this time I place the "Auth.php" inside the same ww directory and its not working.
Also I have placed duplicate copies of "" and "" in both these folders-

But still the program is not working and everytime I run the program it shows the same output - " The User Name or password you entered is not valid." !!

I also created a .htaccess file in I drive where I have placed the & files as I stated earlier.
The path for .htaccess is I:\secret\.htaccess.

I changed the "AllowOverride All" directive in the httpd.conf file to "AllowOverride AuthConfig" under <Directory "H:/xampp/htdocs"> directive.

And I also changed the 'AllowOverride All' directive within <Directory></Directory> directive just above the previous line to "AllowOverride AuthConfig" .
Is it OK or have I made some mistakes??

Earlier before this xampp package was installed ,it used to work when I fidgeted with the settings but now I dont what has happened,I can't figure it out.
Please Help
Thanks in advance
Posts: 15
Joined: 21. June 2011 14:39

Re: HTTP user login

Postby Sharley » 21. August 2011 05:49

Thanks for the detailed content of your post.

When ever you change XAMPP locations using 1.7.3 you need to run the\xampp\setup_xampp.bat file so that the new paths can be corrected through out the XAMPP installation - no need to do this chore manually as it may lead to typos or other mistakes.

When ever you have n Apache server issues read the \xampp\apache\logs\error.log for for reliable clues.

Unless you absolutely know what you are doing, changing settings in the configuration files including ini files can be disastrous.
If you created a back up of the original default configuration files including the ini files then it is often better to return your XAMPP to a known working state, then run the setup_xampp.bat file to do most of the hard yards for you.

Running the setup_xampp.bat file does not apply to XAMPP 1.7.4 unless installing manually the ZIP version as this bat file has very limited functionality where as the bat file in 1.7.3 has some very essential features.

BTW, did you download the new version 3 Control Panel and did you extract the new xampp_control3.exe to the \xampp installation folder and are you using it?

If it's any consolation I have many XAMPP version spread over many hard drives and on many removable media devices that have given me absolutely no issues at all - I use all these XAMPP versions mainly for testing issues presented on these forums.

Good luck and best wishes.
User avatar
AF Moderator
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: HTTP user login

Postby ippo » 21. August 2011 07:00

Hi Sharley :)
Thanks for answering & forgive me for my poor English.
1stly, No,I didn't install the new version 3 Control Panel .
But my problem may not be over by just running the xampp_setup batch file. BTW how to run the batch file?
Also I have checked the myswl.err file(if that is what you meant) and found one line showing a warning -
110821 8:54:32 [Note] Plugin 'FEDERATED' is disabled.
110821 8:54:35 InnoDB: Started; log sequence number 0 73810
110821 8:54:43 [Note] Event Scheduler: Loaded 0 events
110821 8:54:43 [Note] H:\xampp\mysql\bin\mysqld.exe: ready for connections.
Version: '5.1.41' socket: '' port: 3306 Source distribution
110821 10:26:19 [Note] H:\xampp\mysql\bin\mysqld.exe: Normal shutdown

110821 10:26:20 [Note] Event Scheduler: Purging the queue. 0 events
110821 10:26:20 InnoDB: Starting shutdown...
110821 10:26:21 InnoDB: Shutdown completed; log sequence number 0 73810
110821 10:26:21 [Note] H:\xampp\mysql\bin\mysqld.exe: Shutdown complete

I put here the last 2 paragraphs in the error file.
2ndly, No I don't have any backup copies of the ini files. So what will happen if I run the setup_xampp.bat file without replacing the changed php.ini file with the original php.ini file? :roll:
And if you are mentioning of some other logfile in Xampp 1.7.3 pls mention the path of the logfile as well for me to check.

3rdly, you didn't commented on the program above ,whether any changes are needed and anything I am missing out? Running the batch file won't set it up for running the present program which requires PHP to be installed as an Apache module,not as CGI.
Can anyone tell me how to determine which mode my PHP (xampp 1.7.3 version) is starting with ? I know its httpd.conf but which line in that file to check for?
Hope I am clear :roll:
Pls help I am desperate to run this program as it earlier worked in this same configurations.
Posts: 15
Joined: 21. June 2011 14:39

Re: HTTP user login

Postby Sharley » 21. August 2011 08:30

1. You should consider using the New Control Panel, download link in my sig and the Topic here:

2. Your problem may well be fixed by running the setup_xampp bat file as it seems you may have path problems.
What do you see when you type http://locahost in your browser?
It always pays to make sure the XAMPP installation is working fully before adding third part scripts and programs or you will find it difficult to troubleshoot any issues you find, like now for example.

3. The mysql.err log file is not showing any errors.
Sharley wrote:When ever you have an Apache server issues read the \xampp\apache\logs\error.log for reliable clues.
What don't you understand about the path and location of the server's error.log file?

4. You should always create a backup of any configuration file before making any changes.
Make a copy of your current configuration and ini files then double click on the \xampp\setup_xampp.bat file.

5. The program looks in order but without knowing exactly what you have changed in the configuration or ini files it would be difficult to comment.
If the program worked on your I: drive and you have not changed the code then the program is not at issue by not working on the H: drive, is it?
The issue is clearly with your H: drive installation of XAMPP or more precisely with some configuration setting you have changed that perhaps did not need changing.
The program is one you downloaded, not one you created yourself, so any issue with the program should be addressed at the program's author.

6. XAMPP, no matter the version has PHP compiled as a module of Apache.
ippo wrote:I know its httpd.conf but which line in that file to check for?
Incorrect, the settings are contained in xampp\apache\conf\extra\httpd-xampp.conf file and the settings do not need changing from the default settings.

7. If we have a positive result with number 2. then it may be possible to move on and find what your issue is but if, when you installed 1.7.3 of XAMPP, you did not run the setup_xampp.bat file or if you answered any installation question incorrectly then this may be where your problems start.
Did you copy or move the previous XAMPP installation from your I: drive?

ippo wrote:The above program is called "Auth.php" & I have placed it in this directory -
What do you type in the browser to get this Auth.php page?

Two clear lessons that need to be learned for the future.
1. Always make a backup copy of files before editing.
2. Never change any setting unless you are fully aware of the outcome.
User avatar
AF Moderator
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: HTTP user login

Postby ippo » 21. August 2011 09:00

Hi Shirley,
1.All is well here. Everything is working just fine. I don't think there is any path problem else the other php programs wont have run.
2.When i type http://localhost/xampp/ in browser its giving the "Welcome Message " So no path problem is there i hope. :)
Its already showing without running the setup_xampp.bat-
" XAMPP 1.7.3!
You have successfully installed XAMPP on this system!"

Do i still need to run setup_xampp.bat? :roll:
And if yes,it is saying xampp is already setup in my H drive viz. H:\xampp. If i run setup_xampp.bat,it has option 2.Relocate xampp(current path is H:\xampp) it is already set to H:\xampp directory ,then where do i relocate it again? Which option do you want me to choose in the setup options-there is 1 to 7 no of options and none is applicable in my case!
So why do i need to run setup_xampp.bat at all when everything else already working well. Even my other php programs are working!!
3)I have set up a shortcut in my FF browser(FireFox ver 6) and whenever i click the shortcut it shows all the directory structure and files within htdocs where from I run the PHP programs and it works well!! :D
Still FYI, it is "http://localhost/ww/" that is where I am running all the php files & it is working smoothly except for the Auth.php which I run in this same directory.
Its like http://localhost/ww/Auth.php and it gives output as - "The User Name or password you entered is not valid." :(
So why do i at all need to install control panel and run setup.bat :?:
Last edited by ippo on 21. August 2011 09:18, edited 1 time in total.
Posts: 15
Joined: 21. June 2011 14:39

Re: HTTP user login

Postby Sharley » 21. August 2011 09:11

You are telling me now that your XAMPP installation is working fine.

Then if you are having issues with the program, that is beyond the scope of this forum.

As I suggested, you need to contact the program's author if you are having issues with the program.

You don't have to do anything that anyone suggest in these forums, that is your choice and yours alone.

When troubleshooting peoples issues we go through a process of elimination which may involve doing things that seem irrelevant - this is often required because we don't possess powers to read peoples minds, see what they can see on their computers or know what they do without they tell us.

So, I am sorry I can no longer offer any more help now that we have established XAMPP is working as it should.

Bye bye.
User avatar
AF Moderator
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: HTTP user login

Postby ippo » 24. August 2011 07:46

Such a nice & helpful forum.
Was that an answer?? :P
Posts: 15
Joined: 21. June 2011 14:39

Re: HTTP user login

Postby JonB » 25. August 2011 17:50

Since none of us have any idea what auth.php is other than what you say it is (its not any part of XAMMP) or where it came from (surely YOU put it there) AND YOU can't figure it out????

Please give me a help with how we should divine/figure out what is wrong with that code - this is a Forum designed to make XAMMP work - not the My PHP Friends Forum. Why don't you ask at the place where you found that script???

I CAN solve your problem (indirectly) - use Directory Pass -its free and easy to setup, works with XAMPP, and does what you want. (creates Basic Authentication)

Good Luck
User avatar
AF Moderator
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 49 guests