Forum Moderators: coopster
<?php
$p = $_GET['page'];
if(strpos($p, "..")) {
die ("Bad page request");
}
if (!$p) $p = "main";
$content_file=$_SERVER['DOCUMENT_ROOT']."/". $p. ".php";
if (!file_exists($content_file)) {
header("Location:" $_SERVER["PHP_SELF"]});
exit();
}
$title = ($p)? "$p - My Site!" : "Main page - My Site!";
include_once("topbit.php");
include_once($content_file);
include_once("bottombit.php");
?>
I think this has got something to do with the redirection element, but for the life of me, I couldn't get it right. What I am trying to do here is, if $content_file does not exist, I want the visitor to be redirected to the home page.