Solved

PHP if statement multiple conditions

Posted on 2013-10-29
3
482 Views
Last Modified: 2013-10-29
I can find plenty of resources on how to include multiple conditions, but not with a session variable.

So this is my code which is working.  I need to allow this page to be viewed by only two people with member id of 88 and 89.

So if I use this code:

if ($_SESSION[Memberid] != "88") {
header("Location: home.php");
}

It works fine for allowing the one person.  It sends anyone with any other memberid to a home page.

Now, I want to add access for someone with the id of 89. So I tried:

if (($_SESSION[Memberid] != "88") || ($_SESSION[Memberid] != "89")) {
header("Location: wholesale-home.php");
}

Which doesnt work. Any help would be appreciated for this php noob.
0
Comment
Question by:savone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39610421
You need AND '&&'.
if (($_SESSION[Memberid] != "88") && ($_SESSION[Memberid] != "89")) {
header("Location: wholesale-home.php");
}
0
 
LVL 23

Author Closing Comment

by:savone
ID: 39610426
Thanks, I do not know why I didn't see that myself!  Thanks!
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39610467
You're welcome.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question