防止在AdminCP中删除帐户时它仍然登录
问题描述:
我在PHP中删除帐户有问题。具体来说,我开发了后端管理控制面板网站,并在其中有一个功能允许在表Admin_Account中删除账户。但是,当我删除,它也允许删除管理员帐户,目前登录管理控制面板的网站。有人可以帮我预防,不要让它删除一个帐户登录管理员?防止在AdminCP中删除帐户时它仍然登录
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Delete account admin</title>
</head>
<body>
<?php
include("connect.php");
$sl="delete from admin where idAdmin=".$_GET['id'];
if(mysqli_query($con,$sl))
{
echo "<script language='javascript'>alert('Delete successful!');";
echo "location.href='index.php?xem=theloai';</script>";
}
?>
<?php include('close_ketnoi.php');?>
</body>
</html>
答
两件事 1)切勿从表中删除帐户,而不是做软删除(What is the best way to implement soft deletion?) 2)当你火查询,您可以检查是否$ _GET [“身份证”]不等于user_id说明在会话。
还检查代码漏洞,它有很多漏洞。
您的代码容易受到[** SQL注入攻击**](https://en.wikipedia.org/wiki/SQL_injection)的影响。你应该使用[** mysqli **](https://secure.php.net/manual/en/mysqli.prepare.php)或[** PDO **](https://secure.php.net/ manual/en/pdo.prepared-statements.php)准备带有绑定参数的语句,如[**这篇文章**]所述(https://*.com/questions/60174/how-can-i-prevent-sql步喷射功能于PHP)。 –