I use the following code to include page content in a index.php file (template).
if(isset($_GET['page']))
{
include($_GET['page'].'.php');
}
if(isset($_GET['special']))
{
include($_GET['special'].'.php3');
}
The url could look like this: http://www.example.com/?page={PageToShow}
This works fine for Chrome, Firefox and Safari, but the content is not shown in IE 7,8 & 9. Any idea why?
The server side PHP scripts wouldn’t be affected by the browser that you use to view the page, so this looks like a rendering issue – check that the included code produces valid HTML, and that you haven’t got
<html>tags being included within other<html>tags.You might want to rethink the way you’re including page content – doing this via a GET variable is potentially insecure: for a start, it doesn’t limit the files to those within the document root of your website.
At the very least I’d recommend doing some sanity checks on the input files (i.e. are they in the webroot?), but a more modern method is to use .htaccess rewriting to send all requests to
index.php, where you can then choose which files to include depending on the request (take a look at this post for more information).