Jump to content

Display certain pages based on URL - PHP


thenior

Recommended Posts

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

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;
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.