[member=71845]JimL[/member] , That is not really an optimum way to go about it. If you have a thousand pages you will have a thousand cases and will have to maintain it when more pages are added or deleted.
An array of DIS-allowed pages would be better. (IE: header.php, footer.php, menu.php, navbar.php, etc…)
OP, download the PDO bumpstart database from my signature and you will see a clean dynamic way to go about this. It is about as close to a router in MVC as you can get without going MVC. It is exactly what you are looking for and is already in PDO & Bootstrap.
index.php
[php]include_once(’./includes/display_pages.php’);
//----------------------------------------------------------------------------------------
// Include Page Header
//----------------------------------------------------------------------------------------
include_once(’./includes/header.php’);
?>
<?php include_once('./includes/navbar.php'); ?>
<?php include_once('./includes/menu.php'); ?>
<?php include_once("$include"); ?>
</div><!-- /.row -->
</div> <!-- /.container -->
<? include_once('./includes/footer.php'); ?>[/php]
display_pages.php
[php]<?php
/*
- This file: display_pages.php
- Acts as a Router to display pages
- Restricts access to certain files
-
*/
//------------------------------------------------------------------------
// Restrict access to these files
//------------------------------------------------------------------------
// Specify some disallowed paths
$restricted_files = array(
‘header’,
‘footer’,
‘navbar’,
‘menu’
);
//----------------------------------------------------------------------------------------
// Display Pages
//----------------------------------------------------------------------------------------
if (isset($_GET[‘p’]))
{
$page = basename($_GET['p']);
// If it's not a disallowed file, and if the file exists
if (!in_array($page, $restricted_files) && file_exists("./includes/$page.php"))
{
$include = "./includes/$page.php";
}
else
{
// Page Not Found
$include = './includes/404.php';
}
}
else
{
$include = ‘./includes/default.php’;
}
?>[/php]