Using the OR operator in an IF statement
| From: | Tim Burgan | Date: | Sat, 08 Jan 2005 11:02:49 +0000 |
| Subject: | Using the OR operator in an IF statement | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-205862@lists.php.net to get a copy of this message | ||
Hello,
Can someone please correct me on my efforts below.
If I have a condition where I want to test if a variable is not equal to "student", "staff", or "admin".. what's the simplest was to achieve that?
Here's what I tried.. that didn't work:
<?php
if ( ($_POST['usertype'] != "student") || ($_POST['usertype'] != "staff") || ($_POST['usertype'] != "admin") )
{
// ...} ?> And also: <?php if ( ($_POST['usertype'] != "student" || "staff" || "admin" ) {
// ...} ?> I must be using the OR operator the wrong way. Can someone please correct me on this. Thanks very much for your time. Regards Tim Burgan