PHP includes are sometimes used instead of iframes it makes another page appear as though it is actually on the page similar to iframes without all of the scrollbars right making a php include is pretty basic
rite to make the include change without having to make loads of the same page is a bit more complicatedPHP Code:<?php
include ('yourpage.php');
?>
were you want your include to appear put this code
you can change all of thePHP Code:<?php
$_GET['page'];
switch($page)
{
case "home":
include('home.php');
break;
case "news":
include('news.php');
break;
case "tutorials":
include('tutorials.php');
break;
case "contact":
include('contact.php');
break;
case "sitemap":
include('sitemap.php');
break;
case "admin":
include('admin.php');
break;
default:
include('home.php');
break;
}
?>
to the directory of the pages you want and you can also change the name (next to 'case' )PHP Code:case "admin":
include('admin.php');
break;
and what you want the default page to be
now to make the links which will change the include use this:PHP Code:default:
include('home.php');
break;
this would change the include to the page with the 'case' called homeHTML Code:<a href="index.php?page=home">Home</a>
to see an example of this www.xenigma.co.uk
*** Updated ***
I have discovered a new way to use php includes were you do not have to add
everytime to use a new page, the code:PHP Code:case "admin":
include('admin.php');
break;
now the code broken down and the meaningsPHP Code:<?php
if (!isset($page))
{
include("pages/home.php");
}
if(file_exists($_GET['page'].".php")){
include $_GET['page'].'.php';
}
if(file_exists($_GET['page'].".html")){
include $_GET['page'].'.html';
}
if(file_exists($_GET['page'].".txt")){
include $_GET['page'].'.txt';
}
elseif (isset($page) && !@include("$page"))
{
echo "Error Page not found!";
}
?>
starts the php scriptPHP Code:<?php
this part sets what the starting page will be example look at the www.xenigma.co.uk index page there is a description of what was used to develop the site and who it is owned by this is the starting pagePHP Code:if (!isset($page))
{
include("pages/home.php");
}
this sets what file extensions can be used when searching for themPHP Code:if(file_exists($_GET['page'].".php")){
include $_GET['page'].'.php';
}
if(file_exists($_GET['page'].".html")){
include $_GET['page'].'.html';
}
if(file_exists($_GET['page'].".txt")){
include $_GET['page'].'.txt';
}
this is what message will be displayed if the page doesnt exist,PHP Code:elseif (isset($page) && !@include("$page"))
{
echo "Error Page not found!";
}
this ends the php script. Now you can display any page were the include is, all as you need to do now is use the file name example in a linkPHP Code:?>
index.php?page=pages/contact/contact that would open in the include either
pages/contact/contact.php
or
pages/contact/contact.html
or
pages/contact/contact.txt





Reply With Quote






but the page loads in a new window not were i want any ideas?

