Forum Moderators: coopster
<?php include "$page"; ?>
But how do I check to see if the variable actually included a valid file name (and if the file name wasn't valid, display a message staging so)?
Right now, it all works except if the requested file ("$page") isn't there - then it just displays the template with no content.
Since I am paranoid when it comes to security, I don't let the include parameter be variable, so I would do something like the following:
switch($page) {
#
case 'products.html':
include '/content/products.html';
$page_title = 'Our Products';
break;
#
case 'contact_us.html':
include '/content/contact_us.html';
$page_title = 'Contact Us';
break;
#
default:
include '/content/home.html'
$page_title = 'Home Page';
break;
}
eelixduppy:
Not sure I follow your example, since I'm a complete n00b with PHP, but wouldn't this require me to include a case for every page on the site? There are dozens of pages currently and I expect the client to continue to add content, so it doesn't seem practical to me. Regardless, thanks for the response - it gives me something to think about for future reference.