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!

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.