<html>
<body>
<table>
<form action="" method="GET">
<tr><td>Please Enter your KCSE Index Number</td><td><input type="text" id="index_no" name="q" value=""></td></tr>
<tr><td></td><td><input type="Submit" id="print" value="Search"></td></tr>
</form>
</table>
</body>
</html>
<?php
$dir = 'C:\wamp\www\test\admisssionletters';
$exclude = array('.','..','.htaccess');
$q = (isset($_GET['q']))? strtolower($_GET['q']) : '';
$textarea=$_GET['q'];
$res = opendir($dir);
while(false!== ($file = readdir($res)))
{
if(strpos(strtolower($file),$q)!== false &&!in_array($file,$exclude))
{
echo "Click to download or Print your Adm Letter <ahref='$dir/$file'>$file</a>";
echo "<br>";
}
}
closedir($res);
?>
1. the download link isnt working
c:\wamp\www\test\admisssionletters/20400003066_2014.pdf
however if the slash preceding the file name is changed to:
c:\wamp\www\test\admisssionletters\20400003066_2014.pdf
it works, how can i change this in the code?
2. i would also like to restrict values entered in the input text to a specific number, how do i achieve this?