Page 1 of 1
if else multiple times?
Posted: Sun Aug 21, 2005 6:44 am
by ianhull
Is it possible to use if else statements multiple times?
What I mean is
if ($usrlevel == $adminlevel){
do something
if not does it match userlevel
if not redirect to unauthorized.php
If anyone has any advice on this it would be much appreciated.
or even another way to have user levels in my system.
Thanks
Posted: Sun Aug 21, 2005 6:57 am
by raghavan20
looks like you are struggling for a basic if..elseif...else statement
Code: Select all
if (condition1){
}elseif(condition2){
}else{
header(Location: file.php);
}
Posted: Sun Aug 21, 2005 7:02 am
by ianhull
Yeah I am struggling a bit lol,
thanks for this.
Can this go on for a while?
i.e.
Code: Select all
if (condition1){
}elseif(condition2){
}elseif(condition3){
}elseif(condition4){
}else{
header(Location: file.php);
}
etc?
Posted: Sun Aug 21, 2005 7:13 am
by raghavan20
Code: Select all
if (condition1){
}elseif(condition2){
}elseif(condition3){
}elseif(condition4){
}else{
header(Location: file.php);
}
if you are asking whether the above would work...yes
if php can execute one thing like if..elseif..else then it also should be able to execute if..elseif..elseif...else as well

Posted: Sun Aug 21, 2005 7:15 am
by ianhull
Thats cool,
Thank you very much.
Posted: Sun Aug 21, 2005 11:39 am
by ambivalent
You might also want to look at
switch()