Solved

PHP if statement multiple conditions

Posted on 2013-10-29
3
449 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
  • 2
3 Comments
 
LVL 82

Accepted Solution

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

Author Closing Comment

by:savone
Comment Utility
Thanks, I do not know why I didn't see that myself!  Thanks!
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
You're welcome.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now