-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
96 lines (86 loc) · 2.75 KB
/
admin.php
File metadata and controls
96 lines (86 loc) · 2.75 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
require "connect.php";
// If the user is not logged in or not an admin, they should be redirected to the homepage
if ($_SESSION["logged"]) {
$sql = "SELECT * FROM userdata WHERE username = ?;";
$users = $pdo->prepare($sql);
$users->execute([$_SESSION["username"]]);
$user = $users->fetch();
$name = $_SESSION["username"];
$logged = true;
} else {
$name = "Account";
$logged = false;
header("Location: index.php");
}
if ($user["admin"] == "no") {
header("Location: index.php?no");
}
// counting for quick statistics
$sql = "SELECT id FROM gamemerch;";
$productcount = 0;
$stmt = $pdo->prepare($sql);
$stm = $stmt->execute();
foreach ($stmt as $ah) {
$productcount++;
}
$sql = "SELECT id FROM userdata;";
$accountcount = 0;
$stmt = $pdo->prepare($sql);
$stm = $stmt->execute();
foreach ($stmt as $ah) {
$accountcount++;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin panel</title>
<link rel="stylesheet" href="style.css">
<script src="script.js" defer></script>
</head>
<body>
<nav class="topnav" id="myTopnav">
<div>
<a href="index.php">
<h1 class="title">Merchandise</h1>
</a>
</div>
<div class="linkdiv">
<a href="manageusers.php" class="links">Users</a>
<a href="productlist.php" class="links">Products</a>
<a href="addproduct.php" class="links">Add product</a>
</div>
<?php if ($logged) : ?>
<div class="linkdiv account left">
<?php if (isset($user["pfp"])) : ?>
<img src="media/pfp/<?= $user["pfp"] ?>" alt="">
<?php endif; ?>
<div class="dropdown">
<button class="dropbtn"><?= $name ?>
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content accountcontent">
<a href="favs.php">Favorieten</a>
<a href="profile.php">Mijn profiel</a>
<a href="logout.php">Uitloggen</a>
</div>
</div>
</div>
<?php else : ?>
<div class="left">
<a href="login.php" class="links account">Inloggen</a>
</div>
<?php endif; ?>
</nav>
<div class="statistic">
<h1>Snelle statistieken</h1>
<p>Aantal producten: <?= $productcount ?></p>
<p>Aantal accounts: <?= $accountcount ?></p>
<h3 class="notifymsg">Navigeer naar de pagina's in de navbar</h3>
</div>
</body>
</html>