Jay Blanchard wrote: < One of two ways, an intermediary PHP page that asks "Are you sure?" while < carrying the information forward, or a JavaScript pop-up confirmation dialog < box.
< HTH! < Jay < And John Holmes wrote: < Just create a middle page that stores the value of $area_todelete in a < hidden field. < <input type="hidden" name="area_todelete" < value="<?=htmlentities($_POST['area_todelete'])?>"> < You "YES" button would submit it to the delete code you already have, < the "NO" confirmation button would send the user somewhere else, maybe < back to the choose area page. < I hope that's not too confusing. < ---John Holmes... Thanks guys. The intermediate page scheme worked. I added the hidden field like so because I couldn't get "htmlentities" to work: <input type="hidden" name="area_todelete" value="<?=$area_todelete?>"> I appreciate the help. Roger > -----Original Message----- > From: Roger Lewis [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, October 01, 2002 2:51 PM > To: Php-General > Subject: [PHP] Confirm a Deletion > > I know this should be very simple, but I just don't get it. > > I want to delete a record from a mysql table, but prior to deleting the > record I want to receive an option to confirm the deletion. On page one > (kb_areas_add.php) I have a form for inputting the field (area_todelete) > for > the record I want to delete. The form action goes to page two > (kb_areas_delete) on which I am asked to confirm the deletion. I want to > be > able to press the delete button to delete the record, or the cancel button > to cancel the operation. > > The way the code is written, the record gets deleted immediately upon > clicking the submit button on page one. Is there some way I can keep the > script on page two from executing until after I press the confirmation > button? > > Thanks for any suggestions. > > > /* FORM FOR SELECTING AREA TO DELETE */ > > <form action='kb_areas_delete.php' method="post" name="DeleteAnArea"> > <input type="submit" name="DeleteArea" value="Delete Area" border="0"> > Area: <input type="text" name="area_todelete" size="24" border="0"> > </form> > > > /* FORM TO CONFIRM DELETION */ > > <?php > //Delete Areas and All Subjects for the Area > $host = "localhost"; > $user = "root"; > $pass = "pwd"; > $database = "new_kb"; > > // Connecting to the Database > $connect = mysql_connect($host, $user, $pass) or die("could not connect to > server"); > $db_select = mysql_select_db($database) or die("could not select the > database"); > > // Get Area ID > $sql = "SELECT id FROM kb_areas WHERE area = '$area_todelete' "; > $result = mysql_query($sql) or die("could not complete your query for Area > ID"); > $area_id = mysql_result($result, 0, "id"); > ?> > > <p>Confirm Deletion</p> > <p>Are you sure you wish to delete the general area, <b><?php echo > $area_todelete?></b></p> > > <form action='kb_areas_add.php' method="post" name="DeleteTopic"> > <input type="submit" name="DeleteArea" value="Delete" > <b><a > href="kb_areas_add_test.php">Cancel</a></b> > </form> > > <?php > //Delete area from kb_areas > $sql2 = "DELETE FROM kb_areas WHERE id = $area_id"; > $result2 = mysql_query($sql2) or die("couldn't complete your query to > delete > the areas"); > ?> > > <?php > //Delete subjects from kb > $sql3 = "DELETE FROM kb WHERE area_id = $area_id"; > $result3 = mysql_query($sql3) or die("couldn't complete your query to > delete > the subjects"); > ?> > > > > > -- > 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