[PHP] Best Delete Confirmation Script
Greetings. I would like your opinions on the best way to implement an Are You Sure You Want To Do This? dialog for an Admin user when they go to delete a record in a DB. Do you find that a whole page is usually required for this, or does anyone have any nice pop up solutions for such a query. Sure... I hate doing these things too, but when Joe Big Boss gets a bit trigger happy and kills some data he mistakenly thought was a different record. You KNOW who is going to hear about it from on high. :^) Thanks gang! - NorthBayShane -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best Delete Confirmation Script
Shane, I use a javascript prompt. When you click OK, it passes the information on to the PHP script to do the work :) Jeff - Original Message - From: Shane [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, June 27, 2002 12:48 PM Subject: [PHP] Best Delete Confirmation Script Greetings. I would like your opinions on the best way to implement an Are You Sure You Want To Do This? dialog for an Admin user when they go to delete a record in a DB. Do you find that a whole page is usually required for this, or does anyone have any nice pop up solutions for such a query. Sure... I hate doing these things too, but when Joe Big Boss gets a bit trigger happy and kills some data he mistakenly thought was a different record. You KNOW who is going to hear about it from on high. :^) Thanks gang! - NorthBayShane -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best Delete Confirmation Script
It really depends on how complex your site/application is... I really like using a popup window with some Javascript that refreshes the parent/opener page upon updating or executing the PHP. It then closes the popup window. If the user says no, it just closes the window. This gives the use a more of an application feel rather than a website look. Just my opinion... /dkm - Original Message - From: Shane [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, June 27, 2002 12:48 PM Subject: [PHP] Best Delete Confirmation Script Greetings. I would like your opinions on the best way to implement an Are You Sure You Want To Do This? dialog for an Admin user when they go to delete a record in a DB. Do you find that a whole page is usually required for this, or does anyone have any nice pop up solutions for such a query. Sure... I hate doing these things too, but when Joe Big Boss gets a bit trigger happy and kills some data he mistakenly thought was a different record. You KNOW who is going to hear about it from on high. :^) Thanks gang! - NorthBayShane -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best Delete Confirmation Script
This is the one that I use: script language=JavaScript !-- function confirmSubmit(text) { var yes = confirm(text); if (yes) return true; else return false; } // -- /script input type=submit name=Delete value=Delete onclick=return confirmSubmit('Are you sure you want to DELETE this record?') Rick Dost thou love life? Then do not squander time; for that's the stuff life is made of. - Ben Franklin From: Shane [EMAIL PROTECTED] Date: Thu, 27 Jun 2002 09:48:37 -0700 To: [EMAIL PROTECTED] Subject: [PHP] Best Delete Confirmation Script Greetings. I would like your opinions on the best way to implement an Are You Sure You Want To Do This? dialog for an Admin user when they go to delete a record in a DB. Do you find that a whole page is usually required for this, or does anyone have any nice pop up solutions for such a query. Sure... I hate doing these things too, but when Joe Big Boss gets a bit trigger happy and kills some data he mistakenly thought was a different record. You KNOW who is going to hear about it from on high. :^) Thanks gang! - NorthBayShane -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best Delete Confirmation Script
On Thursday, June 27, 2002, at 12:48 PM, Shane wrote: I would like your opinions on the best way to implement an Are You Sure You Want To Do This? dialog for an Admin user when they go to delete a record in a DB. Do you find that a whole page is usually required for this, or does anyone have any nice pop up solutions for such a query. Sure... I hate doing these things too, but when Joe Big Boss gets a bit trigger happy and kills some data he mistakenly thought was a different record. You KNOW who is going to hear about it from on high. :^) It's such a pain in the ass, isn't it? Unless you're using JavaScript, it's like an extra step, and you probably want to re-display the data that's being altered, so you really end up having to make another whole page in order to do it. One way that I like to do it is this: Most of my scripts are really giant switch() statements, and depending on the action variable passed in the querystring, different things happen. So... http://www.domain.com/addrecord.php?action=intro The switch statement reads the $_GET['action'] variable and knows to go to the intro block, where I display the instructions for the page. The next one would be http://www.domain.com/addrecord.php?action=form and is accessible from a hyperlink generated in the intro section. This displays a form that lets the user do some data-changing operation. The form is of POST method, and the form's own action attribute is $_SERVER['PHP_SELF'] . ?action=confirm So now all the user input is in the $_POST array and the action variable's value is add, so the master switch() statement sends the code to the add section. What happens here is, some checks are done on the data to see if it is valid, and if it is valid, the changes are echoed back to the user as a confirm page with a button to resubmit one final time (all the values are thrown into hidden variables). However, note that if the input is NOT valid, we don't have to re-do the code to display the form again, because we can just echo back the error messages and use the switch() statement's ability to drop down to the next block, which is case 'form':. That's why I like switch(), and disagree with Python's lack of it, but whatever. Finally, if the user did have the correct data, and the confirm form with the hidden vars is submitted, it goes to $_SERVER['PHP_SELF'] . ?action=commit and the data is actually inserted into the DB in the commit block of the switch statement. The code looks like this: switch($_GET['action']) { case 'commit': // enter user's data into DB break; case 'confirm': // error check user input // if valid, display a // form action=\ . $_SERVER['PHP_SELF'] . ?action=commit; // if not valid, echo an error message // and thendrop down to the next // block of the switch() (case 'form') // NO BREAK STATEMENT HERE case 'form': // display a form with // form action=\ . $_SERVER['PHP_SELF'] . ?action=confirm; break; default: // you can also call this one case 'intro' if you want // display the instructions for this page } HTH, Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php