Need a general guideline. Login + redirect

I am trying to create a script to log a user in, then depending on which user it is, redirect them to a specific user page. For example, if the manager for xxx department logs in, he sees the xxx department homepage, and the manager for yyy department sees the yyy department homepage.

What do I code to make it recognize certain users and based on that redirect them accordingly? Any help at all will be appreciated. Thanks.

add a column to your users table to identify the type of user I prefer to use integers and call it ‘level’

then you can look at the number inside level to determine where to redirect the user to, for example I have a column called level in a users table:

0 represents a admin
1 represents a moderator
2 represents a normal user

when logging the user in pass the level to a switch

switch ($row[‘level’]){
case 0:
//admin so redirect to admin page
case 1:
//moderator so redirect to moderator page
case 2:
//user so redirect to user page
// no match redirect somewhere else

Thanks! That should do the trick :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service