Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 423
  • Last Modified:

Mysql PHP one password to access multiple databases on same host

I have an app where I want to allow a user to access more than one database on the same host.   They will all enter through the same initial database.

I want to add "restrict access" to each page, so they can only access pages based on their "access level" which is stored in a users table

1 Solution
Mark BradyPrincipal Data EngineerCommented:
I do this for most of my CMS websites. Firstly, in your users table add a column and name it "level" and make it int(1)

Now what I do is make anyone signing up a level 1. When they try to log on and they are level 1 they get a warning they need to check their email and click a link to confirm their email address. Once that has been done they are moved to level 2. From there if you want to assign different levels to different users for different access, just retrieve their level at login stage and do a simple if statement.

if($level == 3){
include("level3_page.php"); // of whatever level 3 page you have
}elseif($level == 4){
} // I think you can see where I'm going with this.

All you need to do is use php sessions() in each page to keep track of that users level then at the top of each page you check to see if that user has the right level to access that page. If not, redirect them back to the page they should be viewing.

you can either do it like that or you can write different code depending on their level but storing their level in the users table is the easiest way I find.
debbieau1Author Commented:
Hi I am currently using levels.  Wasn't sure if the user authentication in one database, carried through if you were using another.


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now