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 Link to comment https://forums.phpfreaks.com/topic/81867-how-to-set-a-page-default-php/ 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? Link to comment https://forums.phpfreaks.com/topic/81867-how-to-set-a-page-default-php/#findComment-415921 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; } ?> Link to comment https://forums.phpfreaks.com/topic/81867-how-to-set-a-page-default-php/#findComment-415924 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? Link to comment https://forums.phpfreaks.com/topic/81867-how-to-set-a-page-default-php/#findComment-415938 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. } ?> Link to comment https://forums.phpfreaks.com/topic/81867-how-to-set-a-page-default-php/#findComment-415942 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? Link to comment https://forums.phpfreaks.com/topic/81867-how-to-set-a-page-default-php/#findComment-415944 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? Link to comment https://forums.phpfreaks.com/topic/81867-how-to-set-a-page-default-php/#findComment-415946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.