Role based login

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pavanesh2009
Forum Commoner
Posts: 30
Joined: Wed Jan 13, 2010 7:24 am

Role based login

Post by pavanesh2009 »

Hello All,

I am a newbie in php world,I have a basic login script where one can come & register them self & then simply logging into site, but here i need to implement a role based login, means if one logging into his id & pwd should be checked in Database & on the basis of role he should redirect to the certain page.

Please suggest me how i can integrate this feature into my existing code.

Thanks in advance,
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Role based login

Post by social_experiment »

This is just a very basic explanation :

Code: Select all

 
<?php
 /*
  Code that checks if your user has submitted valid data ( not empty fields, etc)
 */
 #if the login detai is validated against the database
  if ( databaseCheck = 1 ) {
    header('location: authorisedPage');
    exit();
  }
  else {
   #alternate code if login fails.
  }
  
?>
 
You place this within the page that checks the login against the database ie. loginExecute.php
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Role based login

Post by pickle »

When you check the user credentials, retrieve the user level as well. Then forward the user on depending on what their level is.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
pavanesh2009
Forum Commoner
Posts: 30
Joined: Wed Jan 13, 2010 7:24 am

Re: Role based login

Post by pavanesh2009 »

Thank you very much for helping me out!! :D
pickle wrote:When you check the user credentials, retrieve the user level as well. Then forward the user on depending on what their level is.
Post Reply