Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a set of pages with the following urls:


Each has a structure as follows:

|          A         |
|  |                 |
|B |        C        |
|  |                 |
|          D         |

A: is the "header" area
B: is a list of menu items which show a bunch of menus, sub-menus and the 
   currently selected sub-menu
C: is the content, shown depending on what is selected on B
D: is a common footer to all 

Our current solution is to manage everything not as html files, but as entries in a database table and to generate the html page depending on the url sought...

For example a mod_rewrite rule sends:




and that fetches the html for C from the DB table and shows the page properly.

I want to break away from this model because it is VERY slow on fetching large pages ("C").

My problems are two-fold:

  1. The above pages need to be shown to a "logged-in" user, in which case the header ("A") is dynamically created.
  2. With a view on maintainability, I DON'T want several copies of the same code (whether html or php to float around).

If I simply use pure html / js along with iframes I shouldnt have a problem displaying pages 1 to 4. However, I dont know how to manage the scenario when the user is logged in.

Can you provide more info to help us understanding the problem? Are you using a Content Management System?

no its a custom php website

Are you using frames?

actually we're not using iframes in our present setup, but am not averse to doing so if its makes sense in the ideal solution

How do you do the login now?

we have the login form on the "header section" (A) and when the user is logged in, it customizes the header.

Why is it that your current method is slower than other methods, if the content is the same?

Our current system picks up the content "C" from a table. Since the content is rather large, it slows the page load. I'm trying to move the html content from the db to an actual file on disk. If i just had to deal with logged-out / anonymous users, i would have used iframes to display (A), (B), (C) and (D). And with javascript, navigated to a different page and change contents of (C).

One more perteninet fact - I currently have a php script userheader.php which generates the html for both logged-in and logged-out users (ie "A").

share|improve this question
Can you provide more info to help us understanding the problem? Are you using a Content Management System? Are you using frames? How do you do the login now? Why is it that your current method is slower than other methods, if the content is the same? – Osvaldo Apr 29 '11 at 15:18
@Osvaldo - please have a look at the edited text – siliconpi Apr 29 '11 at 16:02
@Osvaldo - am i going overboard with the explanation? – siliconpi Apr 29 '11 at 17:35
@Frank D - If you are actively involved in the development of a custom application, this question would be a better fit for StackOverflow.com – danlefree Apr 30 '11 at 2:22
@danlefree - it has more to do with how to structure my application, but please feel free to move it to SO ifyou like – siliconpi Apr 30 '11 at 3:24

I often use include()/require() for the various areas, so you could have...


In "A" above. Then the logic to show/hide content based on permissions or a session variable (set after logging in) could show/hide various content.

Something like...

If(isset($_SESSION['logged_in'])){ ?>
    <!-- html here to show when logged in --><?php
} ?>
<!-- html that's shown either way -->

Not sure if that covers what you're looking for. This way, you are checking a session vs. db hits or you hit the db once and set some local vars that filter down into the included files for evaluation.

share|improve this answer
In my example I meant the second code block to be the content of the included file, so "header.php" is running the check for session and then displaying content only meant for users with an active session in place... – digit1001 Jun 9 '11 at 20:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.