I am creating a simple discussion forum, where users can create posts, reply to posts, delete posts, etc. I am having some trouble with deleting posts. I can write the PHP to delete the posts fine, but at the moment the post is instantly deleted (so if someone clicks accidently they have no opportunity to cancel). What I want to do is call a JavaScript function to display a confirm box from PHP, then if the function returns true delete the post, otherwise do nothing. In pseudocode, what I want to do is:
<?php
function display_javascript_confirm_box()
{
if(call_javascript_function()==true)
{
delete();//call PHP function to delete post
}
else
{
return false;
//do nothing
}
}
?>