Advertisement
Guest User

Untitled

a guest
Sep 10th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.56 KB | None | 0 0
  1. <?php
  2. include 'system/config.php';
  3. if(!isset($_GET['key']) && !isset($_GET['username'])){
  4.     die('Invalid Key');
  5. }
  6.  
  7. $key = $_GET['key'];
  8. $user = $_GET['user'];
  9.  
  10. $check = $db->prepare("SELECT * FROM password_keys WHERE `key_id` = :k");
  11. $check->bindParam(':k', $key, PDO::PARAM_STR);
  12. $check->execute();
  13. $check = $check->fetchAll();
  14. foreach($check as $row){
  15.     if($user == $row['user']){
  16.         if(isset($_POST['submit'])){
  17.             $new_pass = $_POST['password'];
  18.             $new_pass_r = $_POST['password_r'];
  19.             if($new_pass == $new_pass_r){
  20.                 $hashed_new = password_hash($new_pass, PASSWORD_DEFAULT);
  21.                 $update = $db->prepare("UPDATE users SET password = :p WHERE username = :u");
  22.                 $update->bindParam(':p', $hashed_new, PDO::PARAM_STR);
  23.                 $update->bindParam(':u', $user, PDO::PARAM_STR);
  24.                 $update->execute();
  25.                 $setUsed = $db->prepare("UPDATE password_keys SET used = 1 WHERE key_id = :k");
  26.                 $setUsed->bindParam(':k', $key, PDO::PARAM_STR);
  27.                 $setUsed->execute();
  28.  
  29.                 echo "<script>alert('Password changed successfully'); window.location.href= 'http://habboarchive.dev'; </script>";
  30.                
  31.             }
  32.         }
  33.         ?>
  34.  
  35. <!DOCTYPE html>
  36. <html>
  37. <head>
  38. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  39. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  40. <link rel="stylesheet" type="text/css" href="assets/css/animate.css">
  41. <link rel="stylesheet" type="text/css" href="assets/css/pnotify.custom.min.css">
  42.     <title>Habbo Archive || Reset Password</title>
  43.  
  44. </head><body>
  45.         <div class="container">    
  46.         <div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">                    
  47.             <div class="panel panel-info" >
  48.                     <div class="panel-heading">
  49.                         <div class="panel-title">Reset password</div>
  50.                
  51.                     </div>    
  52.  
  53.                     <div style="padding-top:30px" class="panel-body" >
  54.  
  55.                         <div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
  56.                            
  57.                         <form id="loginform" method="post" class="form-horizontal" role="form">
  58.                                    
  59.                             <div style="margin-bottom: 25px" class="input-group">
  60.                                        <label>New Password</label>
  61.                                     <input type="password" name="password" class="form-control">                                        
  62.                                     </div>
  63.                                
  64.                             <div style="margin-bottom: 25px" class="input-group">
  65.                                         <label>Retype password</label>
  66.                                         <input type="password" name="password_r" class="form-control">
  67.                                     </div>
  68.                                    
  69.  
  70.                
  71.  
  72.                                 <div style="margin-top:10px" class="form-group">
  73.                                     <!-- Button -->
  74.  
  75.                                     <div class="col-sm-12 controls">
  76.                                       <input id="reset" type="submit" name="submit"  href="#" class="btn btn-success">Login  </a>
  77.                                       </div></div></form></div></div></div></div></body></html>
  78.  
  79.         <?php
  80.     }
  81. } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement