我对以下代码有疑问。我对插入和更新都有一个功能。根据行数,将执行每个函数。我想在执行操作之前提供一个确认框。在取消消息时,它不应该执行该功能。我怎样才能做到这一点?
以下是代码:
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());
}
}
?>`