Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $DATABASE_HOST = 'localhost';
- $DATABASE_USER = 'root';
- $DATABASE_PASS = '';
- $DATABASE_NAME = 'phplogin';
- $con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
- if (isset($_SESSION['loggedin']) && isset($_POST['newpassword'], $_POST['repeatpassword']) && $_POST['newpassword'] === $_POST['repeatpassword']) {
- $password = password_hash($_POST['newpassword'], PASSWORD_DEFAULT);
- $stmt = $con->prepare('UPDATE accounts SET password = ? WHERE id = ?');
- $stmt->bind_param('si', $password, $_SESSION['id']);
- $stmt->execute();
- echo 'Password changed!';
- // Your code/redirect here
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Reset Password</title>
- <link href="style.css" rel="stylesheet" type="text/css">
- <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css">
- </head>
- <body>
- <div class="register">
- <h1>Reset Password</h1>
- <form action="resetpassword.php" method="post" autocomplete="off">
- <label for="password">
- <i class="fas fa-lock"></i>
- </label>
- <input type="password" name="newpassword" placeholder="New Password" id="newpassword" required>
- <label for="password">
- <i class="fas fa-lock"></i>
- </label>
- <input type="password" name="repeatpassword" placeholder="Repeat Password" id="repeatpassword" required>
- <input type="submit" value="Change Password">
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement