Free Web Hosting Forum
(#1 (permalink))
Old
Junior Member
DJDrew22200 is on a distinguished road
 
Posts: 5
Join Date: Oct 2008
Default Using includes and defining URL's - 10-30-2008, 03:08 PM

Hi there,

OK well I've run myself into a little bit of a problem. I am using includes for my header and footer files (using PHP).

Now the problem is that I want to echo (or display) certain information in the header based on the page they're visiting. So what I'd like to do is something like this:

IF the URL is home.php, echo (or display) THIS.
IF the URL is userhome.php, echo (or display) THIS.
IF the URL is recipes.php, echo (or display) THIS.

These "IF" statements are going to be in the header file, so that's why I need to know the URL or page link.

Any help would be appreciated! Thanks
Reply With Quote
(#2 (permalink))
Old
rhuan.barreto's Avatar
Junior Member
rhuan.barreto is on a distinguished road
 
Posts: 11
Join Date: Jul 2008
Location: Brazil
Send a message via MSN to rhuan.barreto
Default 10-30-2008, 06:14 PM

try using the server variable $_SERVER['php_self']
this variable says the actual page that the script is running

any question more?


-----------
Rhuan Samary Barreto
Webmaster
rhuan@tatuinofarol.com.br
www.tatuinofarol.com.br
Reply With Quote
(#3 (permalink))
Old
Junior Member
DJDrew22200 is on a distinguished road
 
Posts: 5
Join Date: Oct 2008
Default 10-31-2008, 04:08 AM

Thanks for the response. So how would I use it?

PHP Code:
$value $_SERVER['php_self']

if (
$value == "index.php"){
echo 
'Is this how I use it?';
}

if (
$value == "userhome.php"){
echo 
'Like this?';

Reply With Quote
(#4 (permalink))
Old
rhuan.barreto's Avatar
Junior Member
rhuan.barreto is on a distinguished road
 
Posts: 11
Join Date: Jul 2008
Location: Brazil
Send a message via MSN to rhuan.barreto
Default 10-31-2008, 09:53 PM

yeah
instead of using if use switch ... case.

tnx


-----------
Rhuan Samary Barreto
Webmaster
rhuan@tatuinofarol.com.br
www.tatuinofarol.com.br
Reply With Quote
(#5 (permalink))
Old
Member
Lovsan is on a distinguished road
 
Posts: 38
Join Date: Oct 2008
Default 10-31-2008, 10:08 PM

Code:
<?php 
include ('header.php');
// list of your pages
$pages = array ("pagez" => "pagez.php", "pagez2" => "pagez2.php");

// page u wanna show
$page = (isset ($_GET["page"])) ? $_GET["page"] : "pagez";
?>
your menu is here? 
<?php
// //time to include the page we want//
if (isset ($pages[$page]))
@include ($pages[$page]);
else
echo "Page not found!";
?>
links -> mypage.com/index.php?page=pagez

this is how im using it
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0
vBulletin Skin developed by: vBStyles.com