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'";
As you're not doing anything with $result, you could try:
mysql_query("DELETE FROM uploads WHERE link = '$url'")or die('Unable to remove from table '.mysql_error());
<center> is deprecated, and has been for a long while. Don't use it - either use inline css or even better, put a class on the elements and assign the centering to that class.
This topic is now closed. New replies are no longer allowed.