(Solved) How do I preload an include?
Posted: Mon Aug 08, 2005 3:08 pm
I am using this code from http://digital-web.com/articles/easypeasy_php_2/. It works beautifully except I get the following error when the page is first loaded.
Quick background: When the page is first loading, it is loading index.html.
INDEX PAGE:
MENU (in the main.php page):
Only when I click one of my menu selections does it bring the following code into play.
So, I figure I need to load index.html?id=home.php first... but how?
TIA,
Now, I have read and I have searched but I am not grasping how to use the ISERROR.PHP Notice: Undefined index: id in C:\\Program Files\\Apache Group\\Apache2\\htdocs\\includes\\main.php on line 65
Quick background: When the page is first loading, it is loading index.html.
INDEX PAGE:
Code: Select all
<?php
// Enable output buffering
// More info: http://www.php.net/ob_start
ob_start();
// Brings in all pre-title elements
include ($_SERVER['DOCUMENT_ROOT'].'/includes/pretitle.php'); ?>
<title>The Biz Locator</title>
<style type="text/css"><!-- @import url("styles/stylesheet.css"); --> </style>
</head>
<body>
<div id="container">
<?php include ($_SERVER['DOCUMENT_ROOT'].'/includes/main.php'); ?></div>
</div>
</body>
</html>Code: Select all
<ul>
<li><a class="menuitem" href="../index.html?id=home" title="Homepage">Home</a></li>
<li><a class="menuitem" href="../index.html?id=about" title="About">About Us</a></li>
<li><a class="menuitem" href="../index.html?id=contact" title="Contact">Contact Us</a></li>
<li><a class="menuitem" href="../index.html?id=sponsors" title="Sponsors">Sponsors</a></li>
<li><a class="menuitem" href="../index.html?id=polpro" title="Contact">Policies/Procedures</a></li>
<li><a class="menuitem" href="../index.html?id=form" title="Contact">Testing Form</a></li>
</ul>Only when I click one of my menu selections does it bring the following code into play.
Code: Select all
59 <?php
60
61 // Define an array of allowed $_GET values:
62 $pagename = array('home','about','contact','sponsors','polpro','form','welcome',);
63
64 // If the page is allowed, include it:
65 if (in_array($_GET['id'], $pagename)) {
66 include ($_SERVER['DOCUMENT_ROOT'] . '/includes/' . $_GET['id'] . '.php');
67 }
68
69 // If there is no $_GET['id'] defined, then serve the homepage:
70 elseif (!isset($_GET['id'])) {
71 include ($_SERVER['DOCUMENT_ROOT'] . '/includes/home.php');
72 }
73
74 // If the page is not allowed, send them to an error page:
75 else {
76 // This sends the 404 header:
77 header("HTTP/1.0 404 Not Found");
78 // This includes the error page:
79 include ($_SERVER['DOCUMENT_ROOT'] . '/includes/error.php');
80 }
81 ?>TIA,