确认之前删除
我想从用户确认之前删除的条目确认之前删除
我呼吁单击删除功能
<li><img src="delete1.png" onClick="delete_records();" alt="delete_records" /></li>
的funcion保存在.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;
}
}
感谢您的帮助:) – user3521051
@ user3521051好,如果我的答案是正确的,请标记为接受.. 。看到这里怎么 http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – scaisEdge
如果我有两个用户访问级别,我怎么能检查相同也删除行之前用_SESSION变量,如果($ _ SESSION [ “的UserLevel”] == '2'){ \t \t> \t \t user3521051
的可能的复制[如何显示一个确认消息之前删除?](HTTP ://stackoverflow.com/questions/9139075/how-to-show-a-confirm-message-before-delete) –