-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedituser.php
More file actions
106 lines (97 loc) · 3.41 KB
/
edituser.php
File metadata and controls
106 lines (97 loc) · 3.41 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
97
98
99
100
101
102
103
104
105
106
<?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");
}
$sql = "SELECT * FROM userdata WHERE id=?;";
$userlist = $pdo->prepare($sql);
$userlist->execute([$_GET["id"]]);
$user = $userlist->fetch();
?>
<!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>Gebruiker bewerken</title>
<link rel="stylesheet" href="style.css">
</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 active">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">
<?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="profile.php">Mijn profiel</a>
<a href="logout.php">Uitloggen</a>
</div>
</div>
</div>
<?php else : ?>
<div>
<a href="login.php" class="links account">Inloggen</a>
</div>
<?php endif; ?>
</nav>
<div class="tablediv noborder">
<form action="edituserdone.php" method="post" enctype="multipart/form-data">
<input type="number" name="id" id="id" class="invisible" value="<?= $_GET["id"] ?>">
<table>
<tr>
<td>Gebruikersnaam</td>
<td><input type="text" name="username" id="username" value="<?= $user["username"] ?>"></td>
</tr>
<tr>
<td>Wachtwoord</td>
<td><input type="password" name="password" id="pwd"></td>
</tr>
<tr>
<td>Profielfoto</td>
<td><input type="file" name="foto" id="foto" value="<?= $user["pfp"] ?>"></td>
</tr>
<tr>
<td>Admin</td>
<td><input type="checkbox" name="admin" id="admin"
<?php if ($user["admin"] == "yes") {
echo "checked";
} ?>></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Wijzig"></td>
</tr>
</table>
</form>
</div>
</body>
</html>