Jump to content

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?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.