adriscoll Posted April 30, 2011 Share Posted April 30, 2011 Hello. How can I insert a prompt to confirm the deletion of a record? Currently I have a page that lists all of the table entries with a url to pass along the variable to identify the record to delete on a hidden, secondary page. Page 1 echo "<a href=\"/administrator/db/event_delete2.php?id=$row[id]\">Delete</a>"; Page 2 mysql_query("DELETE FROM event_schedule WHERE id='$id' LIMIT 1"); The code may be sloppy, but it works. Now I am trying to add the speedbump of the "are you sure you want to delete this record?" Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/235144-confirm-delete-on-submit/ Share on other sites More sharing options...
gizmola Posted April 30, 2011 Share Posted April 30, 2011 You'll need to code up a javascript function that implements your confirmation. Here's one that uses the built-in javascript confirm() dialog. function confirmBox(msg, target) { if (confirm(msg)) { window.location=target; } } And you'd use it like so: click Me Quote Link to comment https://forums.phpfreaks.com/topic/235144-confirm-delete-on-submit/#findComment-1208470 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.