Seaholme Posted July 4, 2010 Share Posted July 4, 2010 Basically I want to include something on all of my pages to check if people are logged in, and if not to throw them an error. The way I see it, I can either stick this on every page individually, or just include a file, and including a file is much more efficient! So I came up with this extremely simple thing: <?php if($loggedin != '1') die("Oops, you're not logged in! <a href=index.php>Log in?</a>"); include('footer.php'); ?> The only problem is that after die() I can't seem to get the footer to appear. All I can think of as an alternative is to go through and put an if()...else() command on every single page individually, which I'd rather not do unless I had to. Does anybody know how I could include the footer on the page somehow, below the die command? I can make it appear above... but then it's not so much a footer xD Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/206709-getting-things-to-appear-after-the-ifdie-command/ Share on other sites More sharing options...
kenrbnsn Posted July 4, 2010 Share Posted July 4, 2010 Change <?php if($loggedin != '1') die("Oops, you're not logged in! <a href=index.php>Log in?</a>"); include('footer.php'); ?> to <?php if($loggedin != '1') { echo "Oops, you're not logged in! <a href=index.php>Log in?</a>"; include('footer.php'); exit(); } include('footer.php'); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/206709-getting-things-to-appear-after-the-ifdie-command/#findComment-1081057 Share on other sites More sharing options...
Alex Posted July 4, 2010 Share Posted July 4, 2010 Alternatively you should redesign your program so you don't need to use the die function in that manner. That would be optimal. Quote Link to comment https://forums.phpfreaks.com/topic/206709-getting-things-to-appear-after-the-ifdie-command/#findComment-1081059 Share on other sites More sharing options...
Seaholme Posted July 4, 2010 Author Share Posted July 4, 2010 Thanks kenrbnsn! Sorted ^___^ Quote Link to comment https://forums.phpfreaks.com/topic/206709-getting-things-to-appear-after-the-ifdie-command/#findComment-1081062 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.