Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include_once("../connect.php") ?>
- <?php include("header.php") ?>
- <body>
- <?php include("top.php") ?>
- <section class="content">
- <div class="admin-wrap">
- <?php
- $valid = false;
- $username = $_POST["username"];
- $passwordold = $_POST["passwordold"];
- $passwordnew = $_POST["passwordnew"];
- $passwordnewconfirm = $_POST["passwordnewconfirm"];
- $stmt = $conn->prepare("SELECT * FROM users WHERE Username='$username'");
- $stmt->execute();
- $results = $stmt->fetchall();
- foreach ($results as $row) {
- if ($username == $row['username'] and $passwordnew == $row['password']) {
- echo "<h2>Nieuwe wachtwoord moet anders zijn dat het oude wachtwoord.</h2>
- <a href='users.php'>
- <button class='form-button' type='button'>
- Terug
- </button>
- </a> ";
- }
- if ($username == $row['username'] and $passwordold == $row['password']) {
- $valid = true;
- }
- else{
- echo "<h2>Oude wachtwoord is niet correct.</h2>
- <a href='users.php'>
- <button class='form-button' type='button'>
- Terug
- </button>
- </a> ";
- }
- }
- if ($valid == true) {
- if ($passwordnew != $passwordnewconfirm) {
- echo "<h2>Nieuwe wachtwoord komt niet overeen</h2>
- <a href='users.php'>
- <button class='form-button' type='button'>
- Terug
- </button>
- </a> ";
- }
- else {
- $sql = "UPDATE users SET password = :password WHERE username = :username";
- $stmt = $conn->prepare($sql);
- $stmt->bindValue(":password", $passwordnew);
- $stmt->bindValue(":username", $username);
- $stmt->execute();
- echo "<h2>Wachtoowrd aangepast naar $passwordnew<br> </h2>
- <a href='users.php'>
- <button class='form-button' type='button'>
- Terug
- </button>
- </a> ";
- }
- }
- ?>
- </div>
- </section>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement