<div class="well"><h3>Manage users</h3></div> <div class="container"> <table class="table table-hover"> <th> <tr> <th>userID</th> <th>username</th> <th>password</th> </tr> </th> <tbody> <?php $get_user_role = $user->get_user_role($_SESSION['user']); if ($get_user_role == 'user') { //if the user role equals user then show a single user(only the logged in user can change his own password) $get_users = $user->get_single_user($_SESSION['user']); } elseif ($get_user_role == 'admin') { // if the user role equals admin then show all users(admin can change all user passwords) $get_users = $user->get_users(); } foreach ($get_users as $user) { $_GET['ID'] = $user['ID']; echo ' <form method="get"> <tr> <td>' . $user['ID'] . '</td> <td>' . $user['email'] . '</td> <td><a href="resetpassword.php?ID=' . $_GET["ID"] . '">Reset wachtwoord</a></td> <td>' . $user['role'] . '</td> </tr> </form>';
<div class="form-group"> <label for="username">Inlognaam</label> <input type="text" name="username" class="form-control" id="username" placeholder="Voer inlognaam in"> </div> <div class="form-group"> <label for="password">Password</label> <input type="password" name="password" class="form-control" id="password" placeholder="Voer wachtwoord aan "> </div> <div class="form-group"> <a href="register.php">Heb je nog geen account? Registreer je dan hier! </a> </div> <button type="submit" class="btn btn-default custombutton" name="submit">Submit</button> </form> <?php if (isset($_POST["submit"])) { $get_user = $user->get_single_user($_POST['username']); $login = $user->user_login($_POST['username'], $get_user['salt'], $_POST['password']); if ($login > 0) { $_SESSION["user_login"] = 1; $_SESSION['username'] = $_POST["username"]; echo '<script>location.href="."</script>'; } elseif (empty($_POST['username']) || empty($_POST['password'])) { echo 'Zorg dat alle velden zijn ingevuld.'; } else { echo 'Gebruikersnaam of wachtwoord fout.'; } } ?> </div> </div> </div>