Page 1 of 1

Role based login

Posted: Fri Jan 15, 2010 4:40 am
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,

Re: Role based login

Posted: Fri Jan 15, 2010 7:34 am
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

Re: Role based login

Posted: Fri Jan 15, 2010 9:49 am
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.

Re: Role based login

Posted: Tue Jan 19, 2010 2:43 am
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.