bobbit Posted January 23, 2008 Share Posted January 23, 2008 Heya! I've been struggling with this for the best part of forever. On the main index of my website I have the following code to include other pages of my site: <? if (isset($_GET['page'])) $page = $_GET['page']; else $page = "home"; if (file_exists("$page.php")) include("$page.php"); else echo "Sorry but the page you requested doesn't appear to exist."; ?> However there is a page that I'm trying to design that needs a similar code in it. Obviously the new page displays with the above include code, but in that page I need its own include code as it's a miniature website within itself. I'm hoping that I can make the address look something like http://www.website.com/?page=newpage&id=videos. So far all I've done is failed Sorry if that makes no sense! Quote Link to comment https://forums.phpfreaks.com/topic/87343-making-page-include-work/ Share on other sites More sharing options...
s0c0 Posted January 23, 2008 Share Posted January 23, 2008 So I gather that someone clicks on a link, technically remains within the same page (we will call this page index.php), but a new page is included? That is strange and horrible for SEO. Are you sure that you don't need to use absolute paths in the file_exists function? What happens when you run this? Is it even making it into the IF block that contains the include function? What steps have you taken to troubleshoot this... ps. please format code pretty <? if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = "home"; } if(file_exists("$page.php")) { include("$page.php"); } else { echo "Sorry but the page you requested doesn't appear to exist."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/87343-making-page-include-work/#findComment-446764 Share on other sites More sharing options...
bobbit Posted January 23, 2008 Author Share Posted January 23, 2008 So I gather that someone clicks on a link, technically remains within the same page (we will call this page index.php), but a new page is included? That is strange and horrible for SEO. Are you sure that you don't need to use absolute paths in the file_exists function? What happens when you run this? Is it even making it into the IF block that contains the include function? What steps have you taken to troubleshoot this... I'm not great at PHP - all I know is the code I gave works fine for one-page includes. All I need to know is how to include a page within an include page. Quote Link to comment https://forums.phpfreaks.com/topic/87343-making-page-include-work/#findComment-446775 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.