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 6785969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:11:25+00:00 2026-05-26T17:11:25+00:00

my website has separate tables for users and admin now i want to give

  • 0

my website has separate tables for users and admin

now i want to give the privilege to access admin area to some users

my problem is with admin and users table

i dont know if i should copy authentication data from user table to the admin table so they can login in to the admin are , or perform a query to search both tables for username and password and just use level column to verify their access?

something like this ?

$sql = "select `password` , `level` from `admin` where `username` = '$username' UNION
(SELECT `password` , `level` FROM `users` where `username` = '$username') LIMIT 1 ";
$result = $db->query($sql);

while($row = mysql_fetch_assoc($result)){
if($password == $row['passwor'] && $row['level'] != 0)
echo 'welcom to admin area';
else
echo 'login faild';
}
  • 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-05-26T17:11:26+00:00Added an answer on May 26, 2026 at 5:11 pm

    I see you are storing passwords in the clear in your database.
    This is a major security risk and should never be done.
    Passwords should always be stored as salted hashes using a secure hash function.
    I also fail to see the use for separate tables for admins and non-admins.

    I recommend you alter your table layout.

    table user
    -------------
    id unsigned integer auto_increment primary key,
    username varchar(100) not null,
    salt varchar(20) not null,
    passhash varchar(48) not null,
    isadmin boolean not null default false
    

    Query your table with:

    SELECT u.id, u.isadmin FROM user u
    WHERE u.username = '$username' 
      AND passhash = SHA2(CONCAT(u.salt, '$password'),512)
      AND isadmin = 1
    

    When creating a user use:

    INSERT INTO user (username, salt, passhash, isadmin) 
       VALUES ('$username', '$salt', SHA2(CONCAT('$salt','$password'),512), '$isadmin')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database which has form authentication tables for an website [let say
So I have this website that has a search feature which searches a table
So I'm making a website that allows users to build contact lists. So their
I am making a table display optimization of my website when the windows width
Now I have my website built on PHP & Mysql. Consider this like a
I'm re-writing a website from the ground up for azure. Each user has ownership
I've got a section on my website, which should be edited by users /
I'm currently developing a PM system for a website, in which users must be
In a website, I need to integrate membership and authentication. So I want to
We have a problem affecting the production environment only. We have a VB6/ASP website

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.