Results 1 to 3 of 3
-
01-23-2006, 08:52 AM #1New Member
- Join Date
- Jan 2006
- Location
- Australia
- Posts
- 2
Login syntax for HTTP authentication
Hi,
I have a question that I feel embarrassed about but I'm new to cPanelX (& Linux) and haven't been able to solve it so here it is.
I have a PHP script that makes use of HTTP authentication. When I open the page the browser (IE/Opera/etc.) pops up a Username/Password input window. No matter how I enter the username/password I just can't get the script to accept the input.
In the past I had problems with Username/Password input when dealing with ftp accounts until I found that I had to enter username@domainname, instead of only the username.
What do I need to enter in the username input field if for example my username was 'tom'? Note that 'tom' is not my cPanelX username but the script login username.
I've tried the following combinations but none work:
tom
tom@domainname
(I'm using PHP version 4.3.10 and cPanel Build 10.8.0-RELEASE 54).
Thanks,
Michael
P.S. Feel free to laugh at me :-)
-
01-23-2006, 08:57 AM #2Web Hosting Master
- Join Date
- Jul 2003
- Location
- Kuwait
- Posts
- 5,104
How are you checking the username/password combination in your script? There is a tutorial at Zend that gives an example.
-
01-23-2006, 09:07 AM #3New Member
- Join Date
- Jan 2006
- Location
- Australia
- Posts
- 2
Thanks for such a quick reply.
Here's my code:
// ~~~~~ LOGIN ~~~~~
// Our 'not logged in function'.
function notLoggedIn() {
global $noLogin;
if ($noLogin != 1) {
header('WWW-Authenticate: Basic realm="Administration"');
header('HTTP/1.0 401 Unauthorized');
echo 'Please Login Correctly.';
exit;
}
}
// Make sure the user is logged in
if (!isset($_SERVER['PHP_AUTH_USER'])) {
notLoggedIn();
} else {
if (($_SERVER['PHP_AUTH_USER'] != $admin_config['user']) ||
($_SERVER['PHP_AUTH_PW'] != $admin_config['pass'])) {
notLoggedIn();
}
}