-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.php
154 lines (131 loc) · 3.59 KB
/
admin.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
require_once './inc/dbc.inc.php';
require_once './inc/Listen.php';
if(!(isset($_SESSION['isAdmin']) && $_SESSION['isAdmin']))
{
header("Location: /");
die();
}
if(isset($_POST['Kategorie']))
{
$addCatQry = $dbc->prepare("INSERT INTO tbl_kategorien(Kategorie_Bezeichnung) VALUES (:katBezeichnung)");
$addCatQry->bindParam(":katBezeichnung", $_POST['Kategorie']);
$addCatQry->execute();
}
if(isset($_GET['delete']))
{
if($_GET['delete'] == "cat")
{
$alert = "<script>$.notify('Kategorie wurde gelöscht', 'success');</script>";
}
else if($_GET['delete'] == "user")
{
$alert = "<script>$.notify('Nutzer wurde gelöscht', 'success');</script>";
}
}
$allUsers = getAllUsers($dbc);
$allCats = getAllCategories($dbc);
?>
<html>
<head>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<link rel="stylesheet" href="stylesheet.css">
<script src="js/jquery-1.12.3.min.js"></script>
<script src="js/notify.min.js"></script> <!-- Notifications (zB. beim Einloggen) -->
<title>Adminübersicht</title>
</head>
<body>
<?php if(isset($alert)) { echo $alert; } ?>
<header>
<div id = "nav-bar-links">
<div>
<a href = "index.php"> <b> START   </b> </a>
<a href = "bereich.php"> <b> MEIN BEREICH  </b> </a>
<?php
if(isset($_SESSION['isAdmin']) && $_SESSION['isAdmin'])
{
echo '<a href = "admin.php"> <b> ADMIN  </b> </a>';
echo '<a href = "admin_suche.php"> <b> LINKVERZEICHNIS  </b> </a>';
}
?>
</div>
<div style = "left: 80%;">
<?php
if(isset($_SESSION['username']))
{
echo '<a href="bereich.php"><b>Hallo, ' . $_SESSION['username'] . '</b></a>';
}
else
{
echo '<a href = "login.php"><b>ANMELDEN</b></a>';
}
?>
</div>
</div>
</header>
<div id = "inhalt">
<br>
<br>
<div id = "ueberschrift">
<h1><b>ADMIN PANEL</b></h1>
<br><br>
</div>
<!---->
<div id="tables">
<table class="demo" id="table1">
<thead>
<tr>
<th colspan="2">NUTZER</th>
</tr>
</thead>
<tbody>
<?php
foreach($allUsers as $user)
{
echo "<tr>";
echo "<td><a href='bereich.php?user=".$user['Benutzer_ID']."'>".htmlspecialchars($user['Benutzer_Name'])."</a></td>";
echo "<td><a href=\"edit_user.php?id=".$user['Benutzer_ID']."\" class=\"btn btn-small\">EDIT</a></td>";
echo "</tr>";
}
?>
<!-- <tr>
<td>Max Mustermann9</td>
<td><input class="btn btn-small" type = "submit" value = "EDIT"></td>
</tr> -->
<tbody>
</table>
<table class="demo" id="table2">
<thead>
<tr>
<th colspan="2">KATEGORIEN</th>
</tr>
</thead>
<tbody>
<?php
foreach($allCats as $cat)
{
echo "<tr>";
echo "<td>".htmlspecialchars($cat['Kategorie_Bezeichnung'])."</td>";
echo "<td><a href=\"edit_cat.php?id=".$cat['Kategorie_ID']."\" class=\"btn btn-small\">EDIT</a></td>";
echo "</tr>";
}
?>
<!-- <tr>
<td>Test</td>
<td><input class="btn btn-small" type = "submit" value = "EDIT"></td>
</tr> -->
<tr>
<form method="POST">
<td><input type = "text" name="Kategorie" placeholder="Kategorie"></td>
<td><input class="btn btn-small" name="submit" type = "submit" value = "Hinzufügen"></td>
</form>
</tr>
<tbody>
</table>
</div>
<br><br><br>
<br><br><br>
<br><br><br>
</div>
</body>
</html>