[SOLVED] die() and exit() stopping html code?
Moderator: General Moderators
[SOLVED] die() and exit() stopping html code?
Hi!
I have a login on my site and I use a checkuser() function everytime the user opens a site where you have to be logged in. So the scripts runs the checkuser function and if the session username/password is wrong, it echos a message, and on the end it runs "exit();" so it doesn't show the rest of the code in the original admin-site file. My problem is that it "stops" the whole site, when the exit(); is executed the server stops sending the rest of the html file. I only want the php code to stop executing, because this is in the middle of a table and the site and error message doesn't look good when it isn't closed. Do you have any tips how to make that possible?
I have a login on my site and I use a checkuser() function everytime the user opens a site where you have to be logged in. So the scripts runs the checkuser function and if the session username/password is wrong, it echos a message, and on the end it runs "exit();" so it doesn't show the rest of the code in the original admin-site file. My problem is that it "stops" the whole site, when the exit(); is executed the server stops sending the rest of the html file. I only want the php code to stop executing, because this is in the middle of a table and the site and error message doesn't look good when it isn't closed. Do you have any tips how to make that possible?
Last edited by heiatufte on Wed Mar 02, 2005 5:59 pm, edited 1 time in total.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
use flow control structures.. for instance:isAdmin would return a false type value when the user isn't an admin..
Code: Select all
if(isAdmin($user,$password))
{
// show admin stuff
}
else
{
// drop kick the user
}-
thegreatone2176
- Forum Contributor
- Posts: 102
- Joined: Sun Jul 11, 2004 1:27 pm
this would be very easy if you are using an include for the table and if you are you could just do
so basically just print the invalid message then include the table so the pages displays properly then end the code
Code: Select all
/*after false info*/
echo "Invalid Info";
include("lefttable.html");
die;If you're in a loop then you can use break(); to get out of it. If you've got a series of statements to run, enclose them in an if{ } block, and set a variable such as $stop = 1 .. and have if ($stop==0) { } surrounding the rest of the PHP code. Theres no way to only stop the PHP.. exit() stops everything..
Wow! Thanks for the replies, the first 3 came within 6 minutes, that was incredible..! I think I'll like it here at this forum 
I decided that the footer or lefttable.html include would be the easiest to make, and would require less changes on the original code than the others. But by all means, thanks for your suggestions!
How do I mark the thread [SOLVED]..?
I decided that the footer or lefttable.html include would be the easiest to make, and would require less changes on the original code than the others. But by all means, thanks for your suggestions!
How do I mark the thread [SOLVED]..?