View Single Post
01-12-2006, 03:19 AM
#7
Nirvana- is offline Nirvana-
Status: Member
Join date: Sep 2005
Location: United States
Expertise:
Software:
 
Posts: 286
iTrader: 0 / 0%
 

Nirvana- is on a distinguished road

  Old

Ok, there are two ways you can use to approach this... Depending on the flexibility that you need, as in new variables and such..
The first way, is more secure, but you also need to define each page as well.
PHP Code:
<?php
switch($id)
{
  default:
    include(
'index.html');
  break;
  case 
"page1":
    include(
'page1.html');
  break;
  case 
"page2":
    include(
'page2.html');
  break;
  case 
"page3":
    include(
'page3.html');
  break;
  case 
"page4":
    include(
'page4.html');
  break;
  case 
"page5":
    include(
'page5.html');
}
?>
your url would be index.php?id=page2 etc. and it would load the "page2.html" inside the content area where you have the include...

the other way, although less secure, is much more flexible...
PHP Code:
<?php
$_GET
["id"] = str_replace("..","",$_GET["id"]);
$val $_GET['id'];
$val .= ".php";
if (isset(
$_GET['id']))
{
  if (
file_exists($val))
  {
    include 
"$val";
  }
  else
  {
    include 
"404.php";
  }
}
else
{
  include 
"defaultpage.php";
}
?>
Ok, this one is a bit more complex, it will get the id that was loaded in the browser... if there isnt one set, it will load defaultpage.php, if it was set, it checks if it exists, then loads it. if it doesnt exist, it simply loads 404.php..

Hope that helps you