Results 1 to 3 of 3
  1. #1
    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 :-)

  2. #2
    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.

  3. #3
    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();
    }
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •