Hi all,
Still struggling a bit with PHP here. I wrote a script a while back that performs a display of various files from a folder. In this script, I have a piece of code that determines whether or not the signed in user is an admin or a user. If admin then it displays an upload form to add more files to the folder, else, no upload form. In the list I would now like to add a delete function the will be displayed for the admin only so that he/she may delete a file from the folder. I am really not sure where to handle this function and would appreciate any help here.
Here is what I have now:
$manager_y = mysql_query("SELECT manager FROM login WHERE user_id='$logged_user_id' AND manager='y'");
$status = mysql_fetch_array($manager_y);
function dirDisplay($path="forms") {
$TrackDir=opendir($path);
$fileList = array();
while ($file = readdir($TrackDir)) {
if ($file != "." && $file != "..") {
array_push($fileList,$file);
}
}
closedir($TrackDir);
sort($fileList);
foreach ($fileList as $value) {
if($status) {
echo "<tr><td><input type=\"submit\" name=\"delete\" value=\"Delete\"><a href=forms/$value target=blank>$value.</a><br /></td></tr>";
}
else {
echo "<tr><td><li><a href=forms/$value target=blank>$value.</a><br /></li></td></tr>";
}
}
}
?>
<blockquote>
<ol><?php
dirDisplay();
?></ol>
</blockquote>
Thanks in advance for any help on this...