Add the following ".htaccess" file, which will rewrite any .html request to add-delete.php. The page add-delete.php will handle the actual page deletion request.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.html$ add-delete.php?request=%{REQUEST_URI} [L,QSA]
</IfModule>
Then have the add-delete.php require the file and then unlink() it. To learn more about unlink go to http://php.net/manual/en/function.unlink.php . The delete-page.php file would look like this:
<?php
// add check to prevent abuse
require($_GET["request"]);
unlink($_GET["request"]);
?>
However, I would probably leave the file up for a few minutes, just in case they hit refresh. In which case I would insert the clean request filename into a MySQL database table.
$db->bind("request",$_GET["request"]);
$db->query("INSERT INTO `delete_pages` (`page_name`) VALUES (:request);");
Then require the file. Then add a Crono event to run a PHP script that deletes all filenames in the table by running a unlink on each result.
$results = $db->query("SELECT `page_id`, `page_name` FROM `delete_pages` WHERE `timestamp` > NOW() - INTERVAL 1 MINUTE); // leave up for 1 or unlink asap
foreach($result as $row){
unlink($row["page_name"]);
$db->bind("page_id",$row["page_id"];
$db->query("DELETE FROM `delete_pages` WHERE `page_id` = :page_id");
}
If you really wanted to do it with Javascript you could do a have a timer than send a xmlhttp request to the sever
<script>
window.onload = function(page_name) {
xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET","delete-page.php?page="+page_name, false); xmlhttp.send(null); document.getElementById("delete-update").value=xmlhttp.responseText; }
</script>
I hope that helps.