thenior Posted August 5, 2009 Share Posted August 5, 2009 Hello, a while ago, I was really getting into PHP, but work has taken me elsewhere, so I am trying to get back into it. I have a section of page that loads various content from other pages (like embedding an iFrame). The plus side to this is when I click a link, I just load that section of the page, rather than having to load the entire page each time. The down side to it is you can never copy URL's, and it breaks the Back button. My thought is then to have some php code that loads the page content (i.e. so you could go to index.php?products.html and it would load just the product section). Can anyone provide me with some code that would do that? I am kind of at loss - major newbie here. Link to comment https://forums.phpfreaks.com/topic/168953-display-certain-pages-based-on-url-php/ Share on other sites More sharing options...
Batosi Posted August 5, 2009 Share Posted August 5, 2009 <?php if ($_GET['sub']) { include $_GET['sub'].'.html'; exit; } ##Normal page script here ?> so the url would be index.php?sub=products Link to comment https://forums.phpfreaks.com/topic/168953-display-certain-pages-based-on-url-php/#findComment-891445 Share on other sites More sharing options...
nbarone Posted August 5, 2009 Share Posted August 5, 2009 It's best to use a switch, because of security issues. <?php switch($_REQUEST['page']){ case "home": include('homepage.html'); break; case "products": include('products.html'); break; default: include('homepage.html'); break; } ?> Link to comment https://forums.phpfreaks.com/topic/168953-display-certain-pages-based-on-url-php/#findComment-891446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.