Forum Moderators: coopster
if they have selected multiple checkboxes and click on the 'delete selected' button the script deleted the ticked off reports.
this is already worjing brillinatly BUT i do with partly with JavaScript.
here's the code:
echo '<td><input type="checkbox" name="delete" onClick="deleteReport('. $row['id'] .')" /></td>';
so when they click on a checkbox the javascript function deleteReport(id) is called.
function deleteReport(id) {
window.location = "index.php?page=reports/mark_delete_report&id=" + id;
}
this script passes the id of the report to the mark_delete_report.php page and that page is updatign the reports table, marking the report with this id to be deleted.
the problem is that everyone can see this javascript function and can see how it works. so it's easy to paste the url end pass an id of a report to delete it.
so i would like to accomplish the same goal with only php.
is it possible? and how?
grtz
That script should check the session/cookies/whatever to ensure that the user is logged in and allowed to modify that report. Plus, to cover myself, I never allow an actual DELETE, I always build in "deleted" columns into every table definition and just toggle that value (you can also add a deleted timestamp and IP of the deleter columns). Then if there ever is an exploit of a public facing script, the worst that can happen is you have to undelete all the rows deleted by that user.
I never allow an actual DELETE, I always build in "deleted" columns into every table definition and just toggle that value
Hmm... That's interesting. I would think about giving that approach a try but I would imagine that I'd end up with a pretty bloated DB after a while. Of course it wouldn't be hard to work in some kind of admin function where I could purge the rows flagged as deleted after a certain period of time?
Do you have anything like this in place?