This topic is locked

Redirect based on login credentials

8/1/2008 10:54:13
PHPRunner General questions
E
ekurzen author

I've created a database where non-admin users can only add records (admin users can add, view, edit, etc.). What I would like to do is set it up so that when an admin user logs in, they're directed to the main list page as always, but when non-admin users login in, they're redirected to the Add page. Is it possible to do a redirect based on the user's access level?
In the past, I've just had non-admin users go directly to the add.html page, which forces them to log in, but the "session expired" message they get at the login page confuses some people, so I'd like a cleaner solution.
Can anyone help?
Cheers,
Eric

E
ekurzen author 8/1/2008

Think I figured it out--it was easier than I thought. I used the following code in AfterSuccessfulLogin:

if ($username == "admin")
{

//********** Redirect to list page ************

header("Location: _students_list.php");

exit();

}
else
{

//********** Redirect to add page ************

header("Location: _students_add.php");

exit();

}