Jay Blanchard wrote:
< One of two ways, an intermediary PHP page that asks "Are you sure?" while
< 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"
< 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
<input type="hidden" name="area_todelete" value="<?=$area_todelete?>">
I appreciate the help.
> -----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
> record I want to receive an option to confirm the deletion. On page
> (kb_areas_add.php) I have a form for inputting the field
> 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
> able to press the delete button to delete the record, or the cancel
> 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
> script on page two from executing until after I press the confirmation
> 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 TO CONFIRM DELETION */
> //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
> $db_select = mysql_select_db($database) or die("could not select the
> // 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 = mysql_result($result, 0, "id");
> <p>Confirm Deletion</p>
> <p>Are you sure you wish to delete the general area, <b><?php echo
> <form action='kb_areas_add.php' method="post" name="DeleteTopic">
> <input type="submit" name="DeleteArea" value="Delete" > <b><a
> //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
> the areas");
> //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
> 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