-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteUser.php
More file actions
74 lines (59 loc) · 1.83 KB
/
Copy pathdeleteUser.php
File metadata and controls
74 lines (59 loc) · 1.83 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
session_start();
$_SESSION["tab"] = "Delete User";
if ($_SESSION["login"] != 1)
echo '<h2 txtcolor="red">Authentication Error!!!</h2>';
else {
include_once('header.php');
$super_pwd = $_POST['super_pwd'];
$username = $_POST['username'];
$err = FALSE;
if (!$err) {
$sql = "select * from User where username = 'SuperAdmin' and password = '$super_pwd'";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
$count = mysqli_num_rows($result);
if ($count != 1) {
echo "Invalid Super Admin Password <br>";
$err = 1;
}
else
echo "Sucessfully Authenticated Super Admin !<br><br><br>";
}
if (!$err) {
$sql = "select * from User where username = '$username'";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
$count = mysqli_num_rows($result);
if ($count != 1) {
echo "Invalid Username <br>";
$err = 1;
}
else
echo "Sucessfully Authenticated username !<br><br><br>";
}
if (!$err) {
$sql = "delete from User where username = '$username'";
if ($con->query($sql) === TRUE) {
echo 'User Deleted Successfully <br><br><br>';
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}
}
if (!$err) {
echo'<h3>List of Users</h3><br>';
$sql = "select username from User where username != 'SuperAdmin'";
$result = mysqli_query($con, $sql);
if ($result->num_rows > 0) {
echo "<table><tr><th>Users</th></tr>";
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["username"]. "</td></tr>";
}
echo "</table> <br><br>";
}
else
echo "No Users Yet";
}
include_once('footer.php');
}
?>