Jump to content

Confirm Delete on Submit


adriscoll

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/235144-confirm-delete-on-submit/
Share on other sites

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

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.