Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9032473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:59:22+00:00 2026-06-16T07:59:22+00:00

Hello fellow programmers and coders. I am developing an enhanced login script based on

  • 0

Hello fellow programmers and coders. I am developing an enhanced login script based on the already great login script by zubrag.

What i am trying to achieve: If the user is an admin, he will be logged in. If the user is a regular user, he will not be logged in.

What happens: The user gets logged in, even if he is not an admin.

Here is a snippet of the code:

// user provided password
if (isset($_POST['access_password'])) {

  $login = isset($_POST['access_login']) ? $_POST['access_login'] : '';
  $pass = $_POST['access_password'];
  if (!USE_USERNAME && !in_array($pass, $users)
  || (USE_USERNAME && ( !array_key_exists($login, $users) || $users[$login] != $pass ) ) 
  ) {
      showLoginPasswordProtect("Incorrect username or password.");
  }

The Part that i am having trouble with:

  elseif (array_key_exists($login, $admins)) {
  showLoginPasswordProtect("User not an admin.");
  }

Rest of the code:

  else {
      // set cookie if password was validated
      setcookie("verify", md5($login.'%'.$pass), $timeout, '/');
      setcookie("user", $login, 0, '/');
      // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
      // So need to clear password protector variables
      unset($_POST['access_login']);
      unset($_POST['access_password']);
      unset($_POST['Submit']);
  }

}

Username and password array:

$users = array(
  'username' => 'password',
  'administrator' => 'administrator-password'
);

Admin array:

$admins = array(
  'administrator'
);

Now picture all of that together, and what would the problem be? (It’s probably really easy, i’m just not a professtional coder.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:59:24+00:00Added an answer on June 16, 2026 at 7:59 am

    Are you sure that admins can login?

    Here you are saying that if the username is in the admin array, deny the acces:

    elseif (array_key_exists($login, $admins)) {
      showLoginPasswordProtect("User not an admin.");
    }
    

     
    What you probably want to do is deny the acces for users not in the admin array:

    elseif (!array_key_exists($login, $admins)) {
      showLoginPasswordProtect("User not an admin.");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello fellow programmers, got a few problem here. I am adding a user control
Hello fellow developers, I am trying to achieve something in Android and I would
hello fellow java developers. I'm having a very strange issue. I'm trying to read
Hello fellow coders & codetts I was wondering, if I needed to create a
Hello , all my fellow coders! I've got a problem ohh chok! .. :P
Hello fellow programmers, as you might know from my previous questions I'm an absolute
Hello Again my fellow programmers out there, I'm designing and programming from scratch a
Hello fellow stackies, I'm developing a site and I have a small problem. It's
Hello fellow programmers. I have a SQL Server 2005 query that is taking a
hello fellow programmers, I followed a tutorial at http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php to send a String encrypted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.