I’m looking for a way to do a function with php when clicking on a link.
I mean to delete an item when clicking on this link. I got my code set up like this:
$files = glob("upload/*.*");
if(count($files) == 0){
echo "No files present";
} else {
foreach ( $files as $file ) {
$array = explode("/", $file);
//echo $array[1] . "<br>";
echo "<tr>";
echo "<td>" . $array[1] . "</td>";
echo '<td><img height="70" width="auto" src=" ' . $file . '" ></td>';
echo '<td><a href="">Delete item</a></td>';
echo "</tr>";
}
}
In your main script:
In your delete script:
You might want to pass in another
$_GETparameter (secret token) for added security – otherwise it’ll open up your uploads directory to permanent threat. You can send a randomsha1()hash or system-defined configuration value, and have your delete script expect a 40-char string.