-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_admin_handle.php
54 lines (39 loc) · 1.8 KB
/
delete_admin_handle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
ini_set('session.save_path', getcwd() . '\sessions');
session_start();
include 'db_connect.php';
$nick = $_POST['nick'];
$pwd = md5($_POST['pwd']);
$_SESSION['delete_nick'] = $nick;
$check_user = mysqli_query($link, "SELECT * FROM users WHERE (email = '$nick' OR nick = '$nick')");
/* echo mysqli_num_rows($check_user) . "</br>";
echo "$nick" . "</br>";
echo "$pwd"; */
if ($nick == "" || $pwd == "7215ee9c7d9dc229d2921a40e899ec5f") {
$_SESSION['message'] = 'Всі поля повинно бути заповнено';
header('Location: delete_admin.php');
} else {
if (mysqli_num_rows($check_user) > 0) {
$check_admin = mysqli_query($link, "SELECT * FROM users WHERE id_user = '" . $_SESSION['id_user'] . "' AND u_password = '" . $pwd . "'");
if (mysqli_num_rows($check_admin) > 0) {
$check_is_admin = mysqli_query($link, "SELECT * FROM users WHERE (email = '$nick' OR nick = '$nick') AND u_status='user'");
if (mysqli_num_rows($check_is_admin) > 0) {
$_SESSION['message'] = 'Не можна позбавити прав aдміністратора того, хто їх не має';
header('Location: add_admin.php');
} else {
$q = "UPDATE users SET u_status = 'user' WHERE nick='" . $nick . "'";
mysqli_query($link, $q);
$_SESSION['message'] = 'Успішно видалено адміністратора';
unset($_SESSION['delete_nick']);
header('Location: admin_page.php');
}
} else {
$_SESSION['message'] = 'Невірно введено пароль!';
header('Location: delete_admin.php');
}
} else {
$_SESSION['message'] = 'Такого користувачаа не існує';
header('Location: delete_admin.php');
}
}
?>