[SOLVED] Header / Footer

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

[SOLVED] Header / Footer

Post by Jim_Bo »

Hi,

Im using index with require header footer for my site .. Im lost on how I can put data in the body of the index page (home) that doesnt show when other links are visited ..?

Code: Select all

<?php

require 'header.php';

switch ($_REQUEST['pages']) {

case 'contact_us':
	require 'contact_us.php';
	break;


case 'about_us':
	require 'about_us.php';
	break;

}

require 'footer.php';
 
?>
Thanks ..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

o.O :?:
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

Hmmz I thought that would be easy to understand .. thought it would be common code ..

I assume you understand the header footer side of the code ..

If I visit http://www.domain.com/index.php?pages=contact_us

I see the contact us form / details ..

If I goto http://www.domain.com .. the body is blank ..

I want to add data into the body of http://www.domain.com .. But in not sure how to get data into there without it displaying on all pages as you move around the links ..

Not sure how to explain it better that that really ..

Thanks ..
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

Did you mean that if none of the case is selected, you wanted to display something on the body?

Code: Select all

require 'header.php';
 
switch ($_REQUEST['pages']) {
 
case 'contact_us':
    require 'contact_us.php';
    break;
 
case 'about_us':
    require 'about_us.php';
    break;

default:
   echo "this is when user a goes to http://www.yourdomain.com"; 
}
 
require 'footer.php';
PS: i really like the php highlight. I believe fedy wrote this part... very nice. First phpbb forums with php code i believe :) (sorry, it's offtopic)
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

that works, or you could create another page (your default page) and include it just as you're including your sub pages.

Code: Select all

require 'header.php';
 
switch ($_REQUEST['pages']) {
 
case 'contact_us':
    require 'contact_us.php';
    break;
 
case 'about_us':
    require 'about_us.php';
    break;

default:
   require 'default.php';
}
 
require 'footer.php';
Then you can put as much stuff in default.php as you would any other index.php page and not clutter up your index.php
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

Thanks guys .. so obvious .. I should have figured that one out :oops:

Thanks ..
Post Reply