commonorx Posted December 16, 2007 Share Posted December 16, 2007 What command does one need to put in thier index.php so that if a page does not exist, it will go to a default page. Such as these pages work: index.php?c=1 index.php?c=4 index.php?c=5 index.php?c=8 But other ones there is nothing there... Thanks Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted December 16, 2007 Share Posted December 16, 2007 are you talking about if a page that is defined by an $_GET variable does not exist? or are you talking about an entire page? Quote Link to comment Share on other sites More sharing options...
rab Posted December 16, 2007 Share Posted December 16, 2007 <?php switch( $_GET['c'] ) { case 'about': // about break; default: // default break; } ?> Quote Link to comment Share on other sites More sharing options...
commonorx Posted December 16, 2007 Author Share Posted December 16, 2007 NOT THIS: if side.html is not in existance <?php include ("side.html"); ?> But if for example: index.php?c=4 Page 4 does not exist, but instead of some error showing up on the page, it just automatically goes to a default page. It looks like rab answered it no? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 16, 2007 Share Posted December 16, 2007 NOT THIS: if side.html is not in existance <?php include ("side.html"); ?> But if for example: index.php?c=4 Page 4 does not exist, but instead of some error showing up on the page, it just automatically goes to a default page. It looks like rab answered it no? I am confused, type properly and tell us the problem in a more understandable human readable format. edit: <?php $page = $_GET['c']; switch($page){ case '1': // Do something break; case '4': // Do something break; case '5': // Do something break; case '8': // Do something break; default: header("LOCATION: default.html"); // Page to redirect the user to, if the page does not exists. } ?> Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 16, 2007 Share Posted December 16, 2007 is "c" a database variable or just a predefined variable in your php page? Quote Link to comment Share on other sites More sharing options...
papaface Posted December 16, 2007 Share Posted December 16, 2007 <?php switch( $_GET['c'] ) { case '1': // code to show page 1 break; default: header('Location: index.php'); } ?> Maybe thats what you need? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.