Page 1 of 1

How to send exit; comand to other location?

Posted: Wed Jun 16, 2004 2:13 pm
by ljCharlie
Is there a way to send the exit; command to a location on the .php file? Here's what I'm trying to do. I want a login page. If the user failed to have the proper authorization, I want to terminate the page from displaying. However, I want to execute the php Exit command at the very end of the </html> tag. Is this possible? The problem of not doing this is that any javascript that comes after the php exit command will not get executed if the php exit command is in the middle of the page. So this is why I like to know if there is a way to exit the exit at the very end of any code.

I have tried function calling...but only to find out that the exit command will get excuted at the location of the function calling and not the location of where the exit command is written.

Any help is greatly appreciated.

ljCharlie

Posted: Wed Jun 16, 2004 2:16 pm
by infolock
well of course. just do something like this

Code: Select all

<?php
//temp IF statement.. replace with whatever it is you are trying to use...
if($password != $mypassword)
{
?>
html data here....
Javascript Here....
html data here....

</html>
<?php
    exit;
}
?>

Posted: Wed Jun 16, 2004 2:30 pm
by ljCharlie
Many thanks for your help. I guess I can use that if there is no other work around.

ljCharlie

Posted: Wed Jun 16, 2004 2:34 pm
by ljCharlie
Well, after looking at my code again, it would be hard to do as you suggested. There are four or five places that I test and user the exit command. It would be hard to incorporate to that many tests.

ljCharlie

Posted: Wed Jun 16, 2004 2:37 pm
by infolock
well, post your code and maybe we can get a better understanding of what you are trying to do? might help us in coming up with a solution at least