jeffeh Posted March 25, 2008 Share Posted March 25, 2008 <?php if ($page == "") $page = "home"; if (!file_exists($page.".php")) $page = "error"; include($page.".php"); ?> how come this isn't displaying the page whenever I use the url http://domain.com/index.php?page=page2 it is only displaying the home page, thanks! Link to comment https://forums.phpfreaks.com/topic/97752-probably-a-simple-include-problem/ Share on other sites More sharing options...
cunoodle2 Posted March 25, 2008 Share Posted March 25, 2008 Probably something to do with your register globals setting. Use this at the top of your script.. <?php $page = isSet($_GET['page']) ? $_GET['page'] : NULL; if ($page == "") $page = "home"; if (!file_exists($page.".php")) $page = "error"; include($page.".php"); ?> Link to comment https://forums.phpfreaks.com/topic/97752-probably-a-simple-include-problem/#findComment-500170 Share on other sites More sharing options...
jeffeh Posted March 25, 2008 Author Share Posted March 25, 2008 Thanks! Solved it with this. <?php if ($_GET['page']) if (file_exists('./'.$_GET['page'].'.php')) @include($_GET['page'].'.php'); else @include('./home.php'); else @include ("./home.php"); ?> Link to comment https://forums.phpfreaks.com/topic/97752-probably-a-simple-include-problem/#findComment-500171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.