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,
Role based login
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Role based login
This is just a very basic explanation :
You place this within the page that checks the login against the database ie. loginExecute.php
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.
}
?>
“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
Re: Role based login
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
Thank you very much for helping me out!!
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.