I'm new php and I hope I can find some kind of help from you guys.
For some reason my script won't work on my Windows 2000 box with IIS 5.
I believe it has something to do with opening directories. Maybe somebosy could post some kind of workaround.
I have:
header (header.inc)
footer (footer.inc)
and my include files
include1.inc
include2.inc
include3.inc
as well as my main template file.
here is the code.
<?
// file: template.php
// include header information
INCLUDE "header.inc";
print "
<table width = 100% border = 0>
<tr>";
// The following cell will hold the move list for the site.
print "<td valign=top>
Choose your link:<BR>
<UL>
<LI><A HREF =
'template.php?topic=include1'>include1 link</A>
<LI><A HREF = 'template.php?topic=include2>include2 link</A>
<LI><A HREF =
'template.php?topic=include3'>include3 link</A>
</UL>
</td>";
// The following cell will include the information requested by the
user.
print "<td valign = top>";
// If no topic selected, display the default content.
IF ($topic == '') :
print "Welcome to my website.";
// Else the user clicked on a link.
// Include content related to that link.
ELSE :
INCLUDE "$topic.inc";
ENDIF;
print "</td></tr></table>";
// Include footer information
INCLUDE "footer.inc";
?>
I found this script which, how the article explains should replace all the hardcoded links between <UL>...</UL> tags and checks the dir for my files. here is the code.
// Open a link to the current directory.
$dir_handle = opendir('.');
// While still files in directory left to look at
while ($file = readdir($dir_handle)) :
// Make sure the file is a link file
if ($file != "." && $file != ".." &&
$file != "header.inc" &&
$file != "footer.inc" &&
$file != "template.php") :
// Replace each underscore ('_') with a blank space.
$name = ereg_replace("_", " ", $file);
// Strip off the .inc from the file name.
$name = ereg_replace(".inc", "", $name);
// Strip off the .inc from the file.
$file = ereg_replace(".inc", "", $file);
// Print link and file name.
print "<LI>
<A HREF = 'template.php?topic=$file'>$name</A>";
endif;
endwhile;
// close the directory
closedir($dir_handle);
It works befor I paste in the second part of the code, but as soon as I paste it in it gives me an error