PHP Navigation
Posted by Pete | Posted in PHP Tutorials | Posted on 09-08-2009-05-2008
0
In this tutorial I will show you how to use PHP Navigation. PHP Navigation is used on lots of websites which uses PHP. In this example we will show you how you can use this instead of an IFrame etc.
An example PHP Navigation url is http://www.yoursite.com/index.php?page=aboutus
"LOCATION_OF_PAGE".
* This is used so that only these pages can be accessed that are in the array.
*/
$pages = array("main" => "main.php",
"about" => "about_us.php",
"contact" => "pages/contact.php");
$default_choice = "main"; // Name of page.
$current_page = strip_tags($_GET['page']); // Get the page variable from the url and remove any html/coding tags.
if (isset($current_page, $pages[$current_page])) // Check if $current_page and $pages[$current_page] are variables with data.
{
@require_once ($pages[$current_page]); // Show the page $current_page.
}
else
{
$require_once($pages[$default_choice]); // The current page is blank or isnt in the array so show the default page.
}
?>
To use this simply put the code where you want the page to show and then use to use it.
If you place the code on index.php then your urls would be index.php?page=NAME_IN_URL replacing NAME_IN_URL with the name in the array.
If you have any questions or need any more help like always just leave a comment also if you like the tutorial id appreciate the feedback.


