Switching Content in HTML Template?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
mjr
New php-forum User
New php-forum User
Posts: 18
Joined: Fri Sep 27, 2002 6:35 am
Contact:

Re: Switching Content in HTML Template?

Post by mjr » Fri Sep 27, 2002 8:09 am

madcat wrote:Hi-

I've been through about 10 tutorials that never finish quite in the way I'd expected them to. I'm looking for a way to bring html content files from separate directories to a variable in my main html template to be displayed.

This way I can have a header.inc, a footer.inc and a content variable controlled by a php menu bar. Seems very simple...

But how do I make it secure?

<?
if(!$file)
{
$file='home';
}
include $DOCUMENT_ROOT . $file . ".inc";
?>

Does $DOCUMENT_ROOT allow me to bring in files from separate sub directories? And will this be the correct method for doing things? Somebody once mentioned something about mod rewrite?

I'm just starting down my PHP path so any help is greatly appreciated.

Matt

try this:

<?
if(!$file)
{
$file='home';
}
$realfilename=$DOCUMENT_ROOT . $file . ".inc"
if(is_file($realfilename)){
include $realfilename;
}else{
echo "<h1>there is no such file</h1>";
}
?>

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests