Jump to content

Double Delete Verification


unemployment

Recommended Posts

How do I apply double delete verification?

 

Right now I have...

 

if (isset($_POST['delete']))
{
if(is_array($_POST['delete'])) {
	$keys = array_keys($_POST['delete']);
	$id = $keys[0];

	$sql = "DELETE FROM `blog_posts` WHERE `post_id` = '$id'";
	header("Location: " . $_SERVER['php_self'] . "?" . $_SERVER['query_string'] );
}
}
if(isset($sql) && !empty($sql)) {
mysql_query($sql) or die(mysql_error());
}

 

which deletes the query great, but I want some box to pop up saying, are you sure you want to delete this post?

 

I'm not sure how to create this verification.

Link to comment
Share on other sites

You could effectively add another IF/ELSE statement before the final deletion expecting a value to return true before the final deletion occurs.

 

Like a mini form

 

<form blah blah blah....>
<input type="text" id="check" name="check">
<input type="submit" name="doit" value="Confirm Deletion">
</form>

 

I don't know javascript or I'd proably give you a nice popup confirming  :P

 

if(isset($_POST['doit']) && ($_POST['check']== "YES")) {

delete stuff

} else {

don't delete my stuff

}

 

But that's how I would do it. You could just have a submit button for yes or now, but hopefully you get the ideal.

Link to comment
Share on other sites

You could effectively add another IF/ELSE statement before the final deletion expecting a value to return true before the final deletion occurs.

 

Like a mini form

 

<form blah blah blah....>
<input type="text" id="check" name="check">
<input type="submit" name="doit" value="Confirm Deletion">
</form>

 

I don't know javascript or I'd proably give you a nice popup confirming  :P

 

if(isset($_POST['doit']) && ($_POST['check']== "YES")) {

delete stuff

} else {

don't delete my stuff

}

 

But that's how I would do it. You could just have a submit button for yes or now, but hopefully you get the ideal.

 

I suppose that is one way of doing it.  I was looking for something a bit more elegant.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.