Re: how to write IF statement for login script

From: Date: Wed, 23 Mar 2005 22:59:33 +0000
Subject: Re: how to write IF statement for login script
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-211427@lists.php.net to get a copy of this message
Thanks, that seems to have worked. M. Sokolewicz wrote:
Nick wrote:
Hi, I have a login script which has worked fine in the past, however i need to change the IF statement. Basically all i want it to do is verify that $squadnum variable is inbetween 1-98 or is 99. I'm not even entirely sure if i need to use the ereg function and i dont think the "1-98" bit is formatted correctly, any help would be much appreciated. Heres the code i have so far: if (ereg("1-98", $squadnum)) { // users with id 1-98 should get sent to squad page
       header("Location: squad.php");
   }  else if(ereg("99", $squadnum)) {  // 99 is the id number of the site administrator
       header("Location: admin.php");
} else {
       header("Location: login.php");
} Thanks, Nick
how about a non regular-expression solution? if($squadnum > 0 && $squadnum < 99) {
    header('Location: squad.php');
} elseif($squadnum == 99) {
    header('Location: admin.php');
} else {
    header('Location: login.php');
}


« previous php.general (#211427) next »