0

Hi,

I'm trying to confirm a Delete action that will remove data from a database. The code is pure php, no jscript etc as I want everything to be server side.

My php file shows a form with the current data found for a venue with 1 or more 'rooms' in it. There are two dB tables, one for venues, one for rooms.

The form has submit buttons to reload the form and I then evaluate the $_POST data to take the relevant action ppprior to echoing the HTML page code out.

One possible action is to add a new room to a venue, that btn works fine.

I now want to add a btn to allow the deletion of a room from a venue. I can do this in a one lick action OK, put I want to add a warning/confirm popup such as:

This action is not reversable - are you sure?

then if the user clicks yes, the php code continues, the row in the room table is deleted and the dB is -searched to show the current data in the form.

Any help on how to get a popup to show before I echo the html code such as..

echo "	<!DOCTYPE HTML PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>";
echo "	<html xmlns='http://www.w3.org/1999/xhtml'>";
echo "	<head>";....

Thanks in anticipation..

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by codejoust
0

You need to use an iframe/ajax to achieve what you want without redirecting the user to another page. If you want to make it a POST request.
For a basic GET, i'd use javascript to confirm.
Simple and Quick:

<a href="delete.php" onclick="return prompt('Are you sure you want to delete?');">Delete</a>
0

Popups aren't very nice, you could use a lightbox with embedded form so that it doesn't get blocked. Ajax is probably your best bet.

0

Popups aren't very nice, you could use a lightbox with embedded form so that it doesn't get blocked. Ajax is probably your best bet.

I definitely agree, but that takes a lot of work...
The easiest would be to have the lightbox load an form (with just ok...) that would post to the delete url, or just ajax-open a form that would post to the delete url.
I had inspiration for that little bit of javascript from rubyonrails scaffolding (which does the same thing in a 2-line mess of code..., to post the url from a hidden form, but still...)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.