as admin you now can't delete your own account
This commit is contained in:
@@ -6,8 +6,11 @@
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
try {
|
||||
$selected_user_id = get_id_user_by_user_id($con, $_SESSION['user_id']);
|
||||
if($selected_user_id != $_POST['id']) {
|
||||
$stmt = $con->prepare("DELETE FROM users WHERE id = :id");
|
||||
$stmt->execute(['id' => $_POST['id']]);
|
||||
}
|
||||
} catch(PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
|
||||
@@ -530,3 +530,15 @@ function get_result_team_station($con, $s_id, $m_id) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
|
||||
function get_id_user_by_user_id($con, $user_id) {
|
||||
try {
|
||||
$stmt = $con->prepare("SELECT * FROM users WHERE user_id = ?");
|
||||
$stmt->bindParam(1, $user_id, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
$stmt->setFetchMode(PDO::FETCH_ASSOC);
|
||||
return $stmt->fetch()['id'];
|
||||
} catch( PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user