Redirecting certain users

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
squirto28
Forum Newbie
Posts: 11
Joined: Mon Mar 22, 2004 9:41 pm

Redirecting certain users

Post by squirto28 »

:?

I have 3 different users and when they log in they are to be taken to a different main menu.
for instance
homepage.com/mainmenu1.php
homepage.com/mainmenu2.php
homepage.com/mainmenu3.php

For instance userlevel field in my database table usertable takes on values from 1-3.

Any suggestions on how to accomplish this???
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

The following code would move the user.

Code: Select all

<?
switch $userlevel {
  case (1):
    header("Location:homepage.com/mainmenu1.php");
    exit;
    break;
  case (2):
    header("Location:homepage.com/mainmenu2.php");
    exit;
    break;
  case (3):
    header("Location:homepage.com/mainmenu3.php");
    exit;
    break;
  default:
    header("Location:homepage.com/errorpage.php");
    exit;
}
?>
It should be noted that header may not be used if you have already output anything. I would recommend you look up header in http://www.php.net for more details.
Post Reply