unemployment Posted March 31, 2011 Share Posted March 31, 2011 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 More sharing options...
Skewled Posted March 31, 2011 Share Posted March 31, 2011 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 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 https://forums.phpfreaks.com/topic/232252-double-delete-verification/#findComment-1194776 Share on other sites More sharing options...
unemployment Posted March 31, 2011 Author Share Posted March 31, 2011 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 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 https://forums.phpfreaks.com/topic/232252-double-delete-verification/#findComment-1194780 Share on other sites More sharing options...
btherl Posted March 31, 2011 Share Posted March 31, 2011 Googling for "javascript confirmation box" will give you the standard javascript method. There are fancier ways, but I can't help you with them as I don't use them myself. Link to comment https://forums.phpfreaks.com/topic/232252-double-delete-verification/#findComment-1194880 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.