Hello, I was wondering if anybody could help me with the following errors:
Notice: Undefined index: DOCUMENT_ROOT in c:\Inetpub\wwwroot\index.php on line 28
and
Notice: Undefined index: page in c:\Inetpub\wwwroot\index.php on line 33
The code for the page is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Website</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<body>
<div style="height:50px;border:1px solid #000;margin-bottom:10px">
</div>
<div style="float:left;width:15%;border:1px solid #000">
<ul style="margin-left:10px;list-style-type:none">
<li><a href="index.php">Home</a></li>
<li><a href="index.php?page=about">About</a></li>
<li><a href="index.php?page=contact">Contact</a></li>
</ul>
</div>
<div style="float:right;width:80%;border:1px solid #000">
<div style="padding:4px">
<?php
# default page
$default = 'home.php';
# set document root path
$base = $_SERVER['DOCUMENT_ROOT'];
# list of all site pages + the id they will be called by
$pages = array('about' => 'about.php','contact' => 'contact.php');
if(array_key_exists($_GET['page'], $pages))
{
foreach($pages as $pageid => $pagename) {
if($_GET['page'] == $pageid && file_exists($base.$pagename))
{
/* if somebody's making a request for ?page=xxx and
the page exists in the $pages array, we display it
checking first it also exists as a page on the server */
include $base.$pagename;
}
} // end foreach
}
else {
/* if the page isn't listed in $pages, or there's no ?page=xxx request
we show the default page, again we'll also just make sure it exists as a file
on the server */
if(file_exists($base.$default)) include $base.$default;
}
?>
</div>
</div>
</body>
</html>
If you need more information, Please ask. Thanks!