SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Admin Login problems

    Im experiencing problems with logging in to admin panel, even im entering the correct username/password.

    I have this config.php file with the following code;

    $admin_password = "admin";
    $admin_username = "admin";

    And in the admin panel php file the following code;

    PHP Code:
    <?php

    include_once("utils.php");
    @
    session_start();
    if(
    $_SESSION[aname] == 4){


    /*if (!isset($_SERVER['PHP_AUTH_USER']))
    {
      header("WWW-Authenticate: Basic realm=\"Cool Stuff\"");
      header('HTTP/1.0 401 Unauthorized');
      echo 'Access Denied';
      exit;
    }
    else
    {
      if (($_SERVER['PHP_AUTH_PW']!=$admin_password) || ($_SERVER['PHP_AUTH_USER']!=$admin_username))
      {
        header('HTTP/1.0 401 Unauthorized');
        echo "<h1>Access Denied</h1>";
        exit;


    Are there any errors to find here? Or is it some issues from the server side?
    Last edited by SpacePhoenix; Aug 18, 2013 at 16:15. Reason: placed php tags around php code

  2. #2
    SitePoint Evangelist bronze trophy
    Join Date
    Feb 2013
    Posts
    500
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Well there are a few things that stand out.

    Don't suppress errors with @ sign.
    You should check if an array key or variable is set before checking against a value AND keys should be in single quotes so it should be something like this.
    PHP Code:
    if(isset($_SESSION['aname']) && $_SESSION['aname'] == 4){ 
    /* is used for commenting out code or adding notes to a page. For example
    PHP Code:
    /*
    This is My Page
    $Variable = "Disabled";
    */ 
    Notice that any code between an opening /* and closing */ lines, like that variable has been disabled.

    You'll see that your php section has been commented out.

    Without more information about utils.php it's hard to see what other issues might be going on.


Bookmarks

Posting Permissions

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