tags:

views:

106

answers:

3

I did my programming before integrating into a design and I have to admit I am quite stuck on the whole situation. Here is my structure:

  • System Files
    • Admin (Admin files)
      • Functions (Admin Function folder)
    • User (User Files)
      • Functions (User Function folder)

Normal Visitor Account Files ( In system files folder).

This whole directory is under public_html which holds my site files. I have tried includes, which seems like a nice clean way of doing it. But the issue I encounter is when I need to modify the header on login. I was just wondering if anyone had any ideas. I tried iframes but i feel it is very unclean.

Thanks!!

A: 

When I need every page to make changes to the header / navigation, I first include my session authorization includes, followed by header includes - however, the header includes do not contain a closing "head" tag. This way, in every individual page I get to continue the "head" section. This makes it possible to overwrite any changes to header / navigation section depending upon the individual page. This of course works well with styles as well because of the cascading hierarchy where the last defined styles have higher precedence.

Example:

-- Authorization file -- authorization.php
<?php session_start(); ... ?>
------------ end of authorization file

-- Header file -- header.html
<!-- Header / Navigation Include -->
<head>
<style> ... </style>
<script> ... </script>
<!-- no /head closing tag here -->
------------ end of header file

-- Individual Page --
<style> ... highest precedence styles ... </style>
<script> ... page specific scripts ... </script>
</head> <!-- finally closing the head tag -->

<?php 
include "authorization.php"
include "header.html" //common header content only

....
?>
------------ end of page
Crimson
I think you need to edit your Invididual Page example so the two includes are called to generate the start of the header, before outputting the end of it. i.e. `<?php include ...?><style> ...</style></head><?php ... output rest of page ...?>`
searlea
unfortunately no luck for me on this one. thank you for your response, everyone else is asleep lol.
Chris B.
A: 

In fact you need to check whatever you want to check before you start any output.

So:

<?php
//do your stuff, includes and more
if(isset($_GET['login']))
{
     //do login stuff
     if($login === false)
    {
          header("Location: index.php");
    }
}

//start output
?>
<html>
etc.

So in your situation you have to reorganize a little bit.

The following is not recommended: If it costs to many efforts... you can use ob_start(); at the beginning of your script and buffer any output.

But again, the last solution is really ugly because it hides the real problem.

Marien
A: 

I simply took all of my PHP code and wrapped my header and footer files around it.

To fix the header problem i used:

ob_start();

and

ob_flush();

Thank you all for your input.

Chris B.