Jump to content

How to force a footer to appear EVEN when an exit() is used?


hatrickpatrick

Recommended Posts

I want footers to appear on all my pages, but I never realised auto_append is ignored with exit;s, which my code is full of... Is there ANY way to force the footer on every page, other than by going through every file I've made and adding it before all the exits? It'd take hours that way, the site is huge already...

I troed adding it to header.inc.php as a <div>, with bottom postsion absolute, but the problem is I need it under the content, not just at the bottom of the browser window...

 

Link to comment
Share on other sites

You should only exit()/die() on fatal errors where you don't want to display the rest of your page.

 

You need to design your logic differently. Rather than exit() use if/else logic to surround your code so that it only executes the portion that you want, then when any block of code is complete, you can continue with the rest of the page, including your footer.

Link to comment
Share on other sites

Content placement and design shouldn't be controlled by your PHP, but by CSS.  Sounds like your code flow isn't organized.

 

Even with exits, you can still code it so the page that is displayed will show all the HTML.

Link to comment
Share on other sites

Using exit() or die() on a production site is unprofessional. We use it day in day around here in code examples, but in reality, production code should -always- display the webpage as the final act of the script. Your code should be making decisions and building up the content. If that's just simply an error message to the user, then that's fine.

 

I'm sympathetic that your site seems rather large to try and perform surgery, but it's the best idea to do so. You should write an exit function, which accepts an error string or whatever. It should send the HTML head section, then any message, then footer stuff and closing body/html tags. Everywhere you have an exit(), insert the function. While this seems laborious, once you have the function setup, any decent text editor will have a find/replace feature in it. Use all tools available, and no undertaking will overwhelm you.

 

PhREEEk

Link to comment
Share on other sites

Content placement and design shouldn't be controlled by your PHP, but by CSS.  Sounds like your code flow isn't organized.

 

Even with exits, you can still code it so the page that is displayed will show all the HTML.

Wrong!

 

php should control content display and output, its called CMS and its the most popular way to design any site.  the trick to making your site work affectively with a php cms engine is how you handle your errors.

 

My cms system has a bit of error checking on the content div section

<?php
//Display all my headers/navi pre my main dynamic content area
if(SERVER_UP != 1 && empty($errors)){
//Server is down
include("Serverdown.php");
}
elseif(!empty($errors)){
//Some sort of error reporting
}
else{
include($pagesrc.".php");
}
//Display rest of page
}
?>

 

The onyl section that is altered is my main content div and the rest of the template is constant

Link to comment
Share on other sites

And I would say that's wrong.  Just because it's not your Style doesn't make it Wrong.

 

PHP should never control actual design, layouts, color, ect.  Only to provide the data to display.

 

 

Wrong!

 

php should control content display and output, its called CMS and its the most popular way to design any site.  the trick to making your site work affectively with a php cms engine is how you handle your errors.

 

My cms system has a bit of error checking on the content div section

<?php
//Display all my headers/navi pre my main dynamic content area
if(SERVER_UP != 1 && empty($errors)){
//Server is down
include("Serverdown.php");
}
elseif(!empty($errors)){
//Some sort of error reporting
}
else{
include($pagesrc.".php");
}
//Display rest of page
}
?>

 

The onyl section that is altered is my main content div and the rest of the template is constant

Link to comment
Share on other sites

Here's the kind of code I'm using. If it's bad coding, I'll remember that in the future, but there's unfortunately no way I can go through the entire site and change it all, it's taken me 4 months just to get the site to where it is now  :(

 

if (!authorized($username,$password))
{
echo "You are not authorized to view this page, please return to the <A HREF=index.php>board index</a>. ";
exit;
}

 

Below that, all the code for the page which you have to be logged in to view... I've never seen a site coded in any other way...?

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.