我正在使用甜蜜警报对话框进行删除确认 .
如果用户单击“是” - >运行SQL以删除 .
如果用户单击“否” - >不执行任何操作,请保留记录 .
if(isset($_POST['button_delete'])) {
echo '
echo 'setTimeout(function (){swal({
title: "Are you sure?",
text:"You will not be able to recover this course!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel please!",
closeOnConfirm: false,
closeOnCancel: false},
function(isConfirm)
{
if(isConfirm)
{
swal("Deleted!", "Your file has been deleted.", "success");';
$deleteCourse = mysqli_real_escape_string($conn, $_POST['button_delete']);
$user = mysqli_real_escape_string($conn, $_SESSION['session_user']);
mysqli_query($conn, "DELETE FROM enroll
WHERE CourseCode LIKE '$deleteCourse'
AND UserID=$user");
echo '
}
else
{
swal("Cancelled", "Your file is safe.", "error");
}})}, 100);';
echo '';
?>
无论我单击“是”还是“否”,SQL仍将运行并删除记录 . 单击是/否时如何使其执行不同的功能?
谢谢你的帮忙 .