<?php
$default = "home.php";
$allowed = array (
'index',
'example',
);
if( isset( $_POST["P"] ) || isset( $_GET["P"] ))
{
$page = isset($_GET["P"]) ? $_GET["P"] : $_POST["P"];
if( in_array( trim ( $page ), $allowed ))
{
$file = $page . ".php";
if( (file_exists( $file )))
{
include( $file );
}
else
{
include( $default );
}
}
else
{
include( $default );
}
}
else
{
include( $default );
}
?>
Currently it searches for files in the folder where index.php. My question is how can I make it search for files in a sub folder? I have all my sub pages in 'pages' folder. Im guessing i have to change this line:
$file = $page . ".php";
But I dont know how to change the path correctly. I think the period in the middle means "current folder" which I have to change to reflect the path..
I got this from: http://scriptplayground.com/tutorials/php/PHP-Navigation/