Need your help again :)

Discussion in 'PHP' started by worlddomain, Aug 8, 2007.

  1. #1
    I just installed a simple script - all has gone well except when I try to log into the admin area it won't let me
    the user name and password are the same as I had entered into the config file

    any idea what could be wrong or what file i should be looking at to correct the problem...thanks

    here is the php of accesscontrol.php

    <?php
    if (!isset($PHP_AUTH_USER)) {
    header('WWW-Authenticate: Basic realm="'.$sitename.' Admin"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Authorization Required.';
    exit;
    } else if (isset($PHP_AUTH_USER)) {
    if (($PHP_AUTH_USER != $adlogin) || ($PHP_AUTH_PW != $adpassword)) {
    header('WWW-Authenticate: Basic realm="'.$sitename.' Admin"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Authorization Required.';
    exit;
    }else{
    session_register("aid");
    session_register("apass");
    }
    }
    ?>
     
    worlddomain, Aug 8, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Replace:
    
    $PHP_AUTH_USER
    
    PHP:
    With
    
    $_SERVER['PHP_AUTH_USER']
    
    PHP:

    And
    
    $PHP_AUTH_PW
    
    PHP:
    With
    
    $_SERVER['PHP_AUTH_PW']
    
    PHP:

    session_register() is deprecated too. Oh well...
     
    nico_swd, Aug 8, 2007 IP
  3. worlddomain

    worlddomain Well-Known Member

    Messages:
    1,138
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Thanks Nico_swd
    I made the changes but it still doesn't work below is what I did - hope i didn't mess it up again :)
    <?php
    if (!isset($_SERVER['PHP_AUTH_USER'])) {
    header('WWW-Authenticate: Basic realm="'.$sitename.' Admin"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Authorization Required.';
    exit;
    } else if (isset($_SERVER['PHP_AUTH_USER'])) {
    if (($_SERVER['PHP_AUTH_USER'] != $adlogin) || ($_SERVER['PHP_AUTH_PW'] != $adpassword)) {
    header('WWW-Authenticate: Basic realm="'.$sitename.' Admin"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Authorization Required.';
    exit;
    }else{
    session_register("aid");
    session_register("apass");
    }
    }
    ?>
     
    worlddomain, Aug 8, 2007 IP