Jump to content

Efficiently redirecting multiple userids


galvin

Recommended Posts

Very simple, I know but I'm out of practice....

 

How can I EFFICIENTLY write code to redirect users with a userid of 1 thru 10?  For example, the code below redirects the person with a userid of 1...

if ($_SESSION['userid'] == '1') {
redirect_to("index.php");
}

But I'd have to write the following for MULTIPLE userids...

if ($_SESSION['userid'] == '1' || $_SESSION['userid'] == '2' || $_SESSION['userid'] == '3' || $_SESSION['userid'] == '4' ***AND SO ON THRU 10***) {
redirect_to("index.php");
}

There has to be a more efficient way to write that, right?  I guess I'd have to loop through it?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.