unidox Posted October 18, 2007 Share Posted October 18, 2007 I have this code: <? if ($_REQUEST['p']){ include("incs/files.inc.php"); } else { echo "We are still in developement"; } Now as of now, if someone types in index.php?p=asd It will not find it, and it will go blank, is there a way I can set a default so if someone does go to asd, it shows the default page? Thanks Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 18, 2007 Share Posted October 18, 2007 Add a check to see if the file exists: <?php if ($_REQUEST['p'] && file_exists('incs/files.inc.php')){ include("incs/files.inc.php"); } else { echo "We are still in developement"; } ?> Ken Quote Link to comment Share on other sites More sharing options...
unidox Posted October 18, 2007 Author Share Posted October 18, 2007 That wouldnt work, cause in mt files.inc.php I have this: $request = $_REQUEST['p']; include("incs/conf.inc.php"); /*************************************************************** ******************* START HOME ********************************* ****************************************************************/ if($request == "admin_home") { Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 18, 2007 Share Posted October 18, 2007 switch($_POST['p']){ case 'x' include (x1); break; case 'x' include (x2); break; default include (default page); break; } //note dont use request bad practice Quote Link to comment Share on other sites More sharing options...
kratsg Posted October 18, 2007 Share Posted October 18, 2007 <? if ($_REQUEST['p']){ include("incs/files.inc.php"); } else { echo "We are still in developement"; } Change this to: <?php $request = $_GET['p'];//safer using $_GET rather than $_REQUEST include("incs/files.inc.php"); } else { echo "We are still in development."; } ?> In files.inc.php, remove that first line and change the conditionals: $request = $_REQUEST['p']; include("incs/conf.inc.php"); /*************************************************************** ******************* START HOME ********************************* ****************************************************************/ if($request == "admin_home") { So you have: include("incs/conf.inc.php"); /*************************************************************** ******************* START HOME ********************************* ****************************************************************/ switch($request){ case 'admin_home' //do something break; default //do something if it doesn't match break; } The reason being is that once you define a variable initially on one page, and include a php file, that variable will be passed through the file so you don't need to redefine it. 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.