Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
587
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.44 KB | None | 0 0
  1. <?php
  2. $DATABASE_HOST = 'localhost';
  3. $DATABASE_USER = 'root';
  4. $DATABASE_PASS = '';
  5. $DATABASE_NAME = 'phplogin';
  6. $con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
  7. if (isset($_SESSION['loggedin']) && isset($_POST['newpassword'], $_POST['repeatpassword']) && $_POST['newpassword'] === $_POST['repeatpassword']) {
  8.     $password = password_hash($_POST['newpassword'], PASSWORD_DEFAULT);
  9.     $stmt = $con->prepare('UPDATE accounts SET password = ? WHERE id = ?');
  10.     $stmt->bind_param('si', $password, $_SESSION['id']);
  11.     $stmt->execute();
  12.     echo 'Password changed!';
  13.     // Your code/redirect here
  14. }
  15. ?>
  16. <!DOCTYPE html>
  17. <html>
  18.     <head>
  19.         <meta charset="utf-8">
  20.         <title>Reset Password</title>
  21.         <link href="style.css" rel="stylesheet" type="text/css">
  22.         <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css">
  23.     </head>
  24.     <body>
  25.         <div class="register">
  26.             <h1>Reset Password</h1>
  27.             <form action="resetpassword.php" method="post" autocomplete="off">
  28.                 <label for="password">
  29.                     <i class="fas fa-lock"></i>
  30.                 </label>
  31.                 <input type="password" name="newpassword" placeholder="New Password" id="newpassword" required>
  32.                 <label for="password">
  33.                     <i class="fas fa-lock"></i>
  34.                 </label>
  35.                 <input type="password" name="repeatpassword" placeholder="Repeat Password" id="repeatpassword" required>
  36.                 <input type="submit" value="Change Password">
  37.             </form>
  38.         </div>
  39.     </body>
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement