i have this sample script i would like to add to my existing php page to search a directory and display the results with a download link. here is the script any ideas where am going wrong?
<?php
$dir = 'my_directory';
$exclude = array('.','..','.htaccess');
$q = (isset($_GET['q']))? strtolower($_GET['q']) : '';
$res = opendir($dir);
while(false!== ($file = readdir($res))) {
if(strpos(strtolower($file),$q)!== false &&!in_array($file,$exclude)) {
echo "<a href='$dir/$file'>$file</a>";
echo "<br>";
}
}
closedir($res);
?>
<form action="my_phpfile" method="get"><input name="q"
type="text"> <input type="submit"></form>