Re: How do I use a confirm box to confirm before deletion from a database
| From: | Lerp | Date: | Mon, 28 Jan 2002 13:39:08 +0000 |
| Subject: | Re: How do I use a confirm box to confirm before deletion from a database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-82397@lists.php.net to get a copy of this message | ||
Hi Ivan, I've this a number of times. What I suggest is that you have two
forms, each with a button on the page that receives the delete request. Both
forms post to the processing page. The first button passes a value called
"dodelete" and the second one passes another value say, "dontdelete". On the
processing page you determine if $dodelete is set, if it is then do your
delete. If not, redirect them to another page and bypass the whole deleteion
process. Below if the code I use on the processing page:
<?php session_start(); ?>
<?php
if (!isset($HTTP_SESSION_VARS["islogged"])){
header("Location:index.php");
}
if(isset($dodelete)){
// connect to db
$connectionToDB = odbc_connect("4gdols4f", "jolf", "rty");
$sqldel = "DELETE FROM RECOMMENDATION WHERE recid ='$recid'";
odbc_do($connectionToDB, $sqldel);
}
else
{
header("Location:login.php");
}
?>
"Ivan Carey" <icarey@iname.com> wrote in message
news:006301c1a7f4$a195ea60$0201a8c0@icarey...
Hello,
Thankyou for your reply.
When a user clicks upon a delete link that deletes a record from a database,
I would like to be able to give them the option to OK or Cancel this action.
I have tried coding the browsers built in confirm box (I can bring up this)
but am unable to combine it with php or a combination of php and a
javascript funtion
Thanks,
Ivan