-1
我有一个代码获取帐户的ID并删除它在数据库中 ,但我需要防止ID 1被删除。防止ID 1被删除
我该怎么做?
<?php
// connect to the database
include('dbconn.php');
// confirm that the 'id' variable has been set
if (isset($_GET['admin_ID']) && is_numeric($_GET['admin_ID']))
{
// get the 'id' variable from the URL
$id = $_GET['admin_ID'];
// delete record from database
if ($stmt = $con->prepare("DELETE FROM tbl_admin WHERE admin_ID = ? LIMIT 1"))
{
$stmt->bind_param("i",$id);
$stmt->execute();
$stmt->close();
}
else
{
echo "ERROR: could not prepare SQL statement.";
}
$con->close();
// redirect user after delete is successful
header("Location: DeleteAdmin.php");
}
else
// if the 'id' variable isn't set, redirect the user
{
header("Location: DeleteAdmin.php");
}
?>
检查'id',如果没有操作删除查询。 –
'WHERE admin_ID <> 1' –
您在代码中使用if语句,因此不确定您需要了解更多信息。 – miken32