Solved

PHP if statement multiple conditions

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

631 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