Solved

PHP if statement multiple conditions

Posted on 2013-10-29
3
473 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
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…

756 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