I have made a file upload system (storing info in database). I also added a page where user gets to see the files he/she has added. Below every file I have given an option for them to delete the file.
My problem here is I am not able to delete the file and remove the entry from the DB too. Could you please help me with this?
This is my my_uploads.php page where use sees the file he has uploaded with the time of upload being fetched from DB.
$query="SELECT * FROM uploads";
echo '<form action="delete.php" method="POST">';
echo "<strong>File: </strong>";
echo "<a href='$new'>$new</a><br/>";
echo "<strong>On: </strong>".$row['datetime'];
echo '<br><input type="submit" name="delete" class="btn btn" value="Delete File"/>';
<center>List of files sorted by date</center>
<?php include $_SERVER["DOCUMENT_ROOT"].'/TestSite/includes/overall/footer.php'; ?>
And my delete.php action file which is supposed to delete the file and remove the file name and it's entries from DB:
$query="DELETE FROM uploads WHERE link = '$url'";