Jump to content

Getting things to appear after the if...die command


Seaholme

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.