awiedman Posted September 25, 2008 Share Posted September 25, 2008 I noticed many websites that have a index.php file and it shows other pages in that index file for example: (index.php?links show links.php) i was wondering how to do this code any helpers? Link to comment https://forums.phpfreaks.com/topic/125709-many-webpages-in-one-php-file/ Share on other sites More sharing options...
Asheeown Posted September 25, 2008 Share Posted September 25, 2008 You can do this: index.php?Page=Links index.php: <body> <?php if($_GET['Links']) { include("Links.php"); } ?> </body> If you do multiple pages do NOT do <?php include($_GET['Page'] . ".php"); ?> That leads to all types of injection and you don't want any part of that, if you get to use many more pages just use a switch statement and put all your possibilities in there. Link to comment https://forums.phpfreaks.com/topic/125709-many-webpages-in-one-php-file/#findComment-649998 Share on other sites More sharing options...
rarebit Posted September 25, 2008 Share Posted September 25, 2008 need to look at the mod_rewrite module for your server... or as fearsoldier states, maybe I didn't read correctly? Link to comment https://forums.phpfreaks.com/topic/125709-many-webpages-in-one-php-file/#findComment-649999 Share on other sites More sharing options...
awiedman Posted September 25, 2008 Author Share Posted September 25, 2008 now how would i make it work for multiple pages? like: index.php?Page=Links shows Links.php index.php?Page=Downloads shows Downloads.php index.php?Page=AboutMe shows AboutMe.php Link to comment https://forums.phpfreaks.com/topic/125709-many-webpages-in-one-php-file/#findComment-650009 Share on other sites More sharing options...
Asheeown Posted September 25, 2008 Share Posted September 25, 2008 As I said the switch statement is best for organization. <?php switch ($_GET['Page']) { case "Links": include("Links.php"); break; case "About": include("AboutUs.php"); break; case "Contact": include("ContactUs.php"); break; default: echo("The page you have requested either no longer exists or has been moved to another location."); } ?> Link to comment https://forums.phpfreaks.com/topic/125709-many-webpages-in-one-php-file/#findComment-650014 Share on other sites More sharing options...
awiedman Posted September 25, 2008 Author Share Posted September 25, 2008 Thanks, you rock! Link to comment https://forums.phpfreaks.com/topic/125709-many-webpages-in-one-php-file/#findComment-650015 Share on other sites More sharing options...
rarebit Posted September 25, 2008 Share Posted September 25, 2008 if($_GET['Links']) { $link = $_GET['Links']; if(strcmp($link,'home')==) { // display home page } elseif(strcmp($link,'help')==0) { // display help page } else { // display default } } something like that... or yes, something like fearsoldiers' beat me to... Link to comment https://forums.phpfreaks.com/topic/125709-many-webpages-in-one-php-file/#findComment-650016 Share on other sites More sharing options...
dropfaith Posted September 25, 2008 Share Posted September 25, 2008 this although i see it all the time seems like a horrible move for seo? true or false just wondering would this hurt seo Link to comment https://forums.phpfreaks.com/topic/125709-many-webpages-in-one-php-file/#findComment-650057 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.