switch statement with no page found option
All,
I have been running this for quite some time and it's solid, but I want to be able to utilize a page not found option.
Code:
<?php
switch($_GET['page']){
case "contact":
$displaypage = "page_content/contact.php";
$title = "Contact";
$description = "";
$keywords = "";
break;
case "about":
$displaypage = "page_content/forum.php";
$title = "About";
$description = "";
$keywords = "";
break;
default:
$displaypage = "page_content/home.php";
$title = "Home";
$description = "";
$keywords = "";
break;
}
?>
I want users to be able to get a "page not found" message or set in place a 404.php page if they type domain.com/index.php?page=abc or they misspell the page name like "cntact"
This switch statement can get pretty long obviously if there are many pages, so maybe there is a better way to write this with say an array like...
Code:
$page = array('home', 'about', 'contact');
$titles = array('Home', 'About us', 'Contact Us');
Thank you