删除前确认
Confirmation Before Delete
我想在删除条目之前向用户确认
我在点击时调用删除函数
<li><img src="delete1.png" onClick="delete_records();" alt="delete_records" /></li>
函数保存在 .js 文件中
function delete_records()
{
document.frm.action = "delete.php";
document.frm.submit();
}
delete.php如下
<?php require 'connections/connections.php'; ?>
<?php require 'includes/higherauth.php';// for user access level check
?>
<?php
// To stop accessing the page without login
if(isset($_SESSION["id"])){
}else{
header('Location: logIn.php');
}
?>
<?php
error_reporting(0);
$rado = $_POST['rado'];
$chkcount = count($rado);
if(!isset($rado))
{
?>
<script>
alert('At least one checkbox Must be Selected !!!');
window.location.href = 'account.php';
</script>
<?php
}
else
{
for($i=0; $i<$chkcount; $i++)
{
$del = $rado[$i];
$sql=$con->query("DELETE FROM mntr WHERE id=".$del);
}
if($sql)
{
?>
<script>
alert('<?php echo $chkcount; ?> Records Was Deleted !!!');
window.location.href='account.php';
</script>
<?php
}
else
{
?>
<script>
alert('Error while Deleting , TRY AGAIN');
window.location.href='account.php';
</script>
<?php
}
}
?>
请帮我添加确认删除的警告
一种简单的方法是添加确认并测试响应
function delete_records()
{
var conf= confirm("Do you really want delete?");
if (conf== true){
document.frm.action = "delete.php";
document.frm.submit();
}else{
return;
}
}
我想在删除条目之前向用户确认
我在点击时调用删除函数
<li><img src="delete1.png" onClick="delete_records();" alt="delete_records" /></li>
函数保存在 .js 文件中
function delete_records()
{
document.frm.action = "delete.php";
document.frm.submit();
}
delete.php如下
<?php require 'connections/connections.php'; ?>
<?php require 'includes/higherauth.php';// for user access level check
?>
<?php
// To stop accessing the page without login
if(isset($_SESSION["id"])){
}else{
header('Location: logIn.php');
}
?>
<?php
error_reporting(0);
$rado = $_POST['rado'];
$chkcount = count($rado);
if(!isset($rado))
{
?>
<script>
alert('At least one checkbox Must be Selected !!!');
window.location.href = 'account.php';
</script>
<?php
}
else
{
for($i=0; $i<$chkcount; $i++)
{
$del = $rado[$i];
$sql=$con->query("DELETE FROM mntr WHERE id=".$del);
}
if($sql)
{
?>
<script>
alert('<?php echo $chkcount; ?> Records Was Deleted !!!');
window.location.href='account.php';
</script>
<?php
}
else
{
?>
<script>
alert('Error while Deleting , TRY AGAIN');
window.location.href='account.php';
</script>
<?php
}
}
?>
请帮我添加确认删除的警告
一种简单的方法是添加确认并测试响应
function delete_records()
{
var conf= confirm("Do you really want delete?");
if (conf== true){
document.frm.action = "delete.php";
document.frm.submit();
}else{
return;
}
}