I have a doubt in the following code. I have a single function for both Insert and Update. Based on the row count each function will be executed. I want to provide a Confirmation box before performing the operation. On cancel message it should not perform the function. How can I do this?
Following is the code:
if (isset($_POST['Save']))
{
$query = "SELECT * FROM `table_name` WHERE `submission_id` = '$submission_id'";
$sqlsearch = mysql_query($query);
$resultcount = mysql_num_rows($sqlsearch);
if ($resultcount > 0)
{
mysql_query("UPDATE `table_name` SET
`name` = '$name',
`email` = '$email',
`phone` = '$phonenumber',
`subject` = '$subject',
`message` = '$message'
WHERE `submission_id` = '$submission_id'") or die(mysql_error());
}
else
{
mysql_query("INSERT INTO `table_name` (submission_id, formID, IP,
name, email, phone, subject, message)
VALUES ('$submission_id', '$formID', '$ip',
'$name', '$email', '$phonenumber', '$subject', '$message') ") or die(mysql_error());
}
}
?>`
Try javascript
confirmfunction ononsubmitform actionUpdated:
Have a hidden value in form, call the js action if id is set, something like this
then,