forked from Lake-Tuggeranong-College/CyberCity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserSearch.php
64 lines (53 loc) · 1.68 KB
/
userSearch.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
55
56
57
58
59
60
61
62
63
64
<?php include "template.php";
if (!authorisedAccess(false, false, true)) {
header("Location:index.php");
}
/** @var $conn */
$username = "";
$accessLevel = "";
$enabled = "";
?>
<title>Search Users</title>
<h1>Search Users</h1>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="POST">
<div class="form-group">
<label>Type in Username</label>
<input type="search" name="search-user" class="form-control" required="required"/>
</div>
<center>
<button name="search" class="btn btn-primary">Search</button>
</center>
</form>
<?php
$userCount = $conn->query("SELECT COUNT(*) FROM `Users`");
$row = $userCount->fetch();
$userCountNumber = $row[0];
// this uses row 0 (id) to display how many user accounts have been created
echo "<br>The number of users is: " . $userCountNumber . "</br>";
if (isset($_POST['search'])) {
$userToSearch = sanitise_data($_POST['search-user']);
$userSearch = $conn->query("SELECT * FROM Users WHERE Username='$userToSearch'");
$row = $userSearch->fetch();
$userNumberOfRows = $row[0];
if ($userNumberOfRows > 0) {
$username = $row[1];
$accessLevel = $row[3];
$enabled = $row[4];
?>
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<h3>Username: <?php echo $username; ?></h3>
<h3>AccessLevel: <?php echo $accessLevel; ?></h3>
<h3>Enabled: <?php echo $enabled; ?></h3>
</div>
</div>
<?php
} else {
//echo "No Users Found";
echo "<br> No user found under:" . $userToSearch . "</br>";
}
}
?>
<br>
</div>