Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
PHP Break from If statement
Name: mikedfrank Date: January 10, 2005 at 16:45:05 Pacific OS: Win98/XP CPU/Ram: 512
Comment:
Does anybody know if it's possible to break out of an if statement? Thanks for your help.
Name: Laler Date: January 10, 2005 at 19:07:59 Pacific
Reply:
can you describe why do you want to break the if statement?
if it's about many if, can it be done by using elseif?
^o^ are you in Asia? do you watch Animax Asia? Please Vote
0
Response Number 2
Name: mikedfrank Date: January 10, 2005 at 21:10:40 Pacific
Reply:
It's a login script, with "is valid user check" nested in another required IF. If the user is invalid, display the page code at the bottom of this script, outside of the php code. No elses can be used.
0
Response Number 3
Name: Laler Date: January 11, 2005 at 02:40:07 Pacific
Reply:
ok
cmiiw but as far as I know we can't break the IF... we can however:
if (notauthenticated){ header ("Location: badlogin.php"); exit(); }
to force redirection and putting exit() to make sure the current script ends... I use this quite often...
in your case, if it's too complicated to put the badlogin into another page, maybe you can use something like this:
if (something){
if (notauthenticated){ $badlogin = TRUE; }
}
//and enclose the badlogin codes at the bottom with another if
if (isset ($badlogin)) and ($badlogin == TRUE)){ ?>
<!-- html outside php goes here -->
<?php } ?>
did that make sense =D
^o^ are you in Asia? do you watch Animax Asia? Please Vote
Summary: Hi all, I am new to PHP and web programming. I have a very simple question, I have following simple code: **************************** <?php if (isset($submit)) { echo "If is executed"; } else { ...
Summary: Michael Thanks very much for that reply it was a great starter for me. The Period 1, Period 2 is just a bit of text for the staff intranet just as a value added feature really. Our period 3 starts at ...
Summary: so the page is kinda like being opened like a text document? like .txt? if that is so, and if you are using a windows machine, you could replace the line break with \r\n and that would make all the th...