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
https://forums.phpfreaks.com/topic/232252-double-delete-verification/
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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.