You are here: Re: [PHP] how to write IF statement for login script « PHP « IT news, forums, messages
Re: [PHP] how to write IF statement for login script

Posted by M. Sokolewicz on 03/24/05 00:19

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');
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация