Advertisement
Guest User

Untitled

a guest
Apr 9th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <?php
  2. if(isset($_GET['id']) && isset($_GET['token'])){
  3. require 'base.php';
  4. require 'functions.php';
  5. $req = $pdo->prepare('SELECT * FROM users WHERE id = ? AND reset_token IS NOT NULL AND reset_token = ? AND reset_at > DATE_SUB(NOW(), INTERVAL 30 MINUTE)');
  6. $req->execute([$_GET['id'], $_GET['token']]);
  7. $user = $req->fetch();
  8. if($user){
  9. if(!empty($_POST)){
  10. if(!empty($_POST['password']) && $_POST['password'] == $_POST['password_confirm']){
  11. $password = password_hash($_POST['password'], PASSWORD_BCRYPT);
  12. $pdo->prepare('UPDATE users SET password = ?, reset_at = NULL, reset_token = NULL')->execute([$password]);
  13. session_start();
  14. $_SESSION['flash']['success'] = 'Votre mot de passe a bien été modifié';
  15. $_SESSION['auth'] = $user;
  16. header('Location: compte.php');
  17. exit();
  18. }
  19. }
  20. }else{
  21. session_start();
  22. $_SESSION['flash']['error'] = "Ce token n'est pas valide";
  23. header('Location: connexion.php');
  24. exit();
  25. }
  26. }else{
  27. header('Location: connexion.php');
  28. exit();
  29. }
  30. ?>
  31. <html>
  32. <head>
  33. <meta charset="utf-8" />
  34. <title>Mangas'Fan</title>
  35. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  36. <link rel="icon" href="../images/favicon.png"/>
  37. <link rel="stylesheet" href="http://www.mangasfan.pe.hu/feuille.css" />
  38. </head>
  39. <body>
  40. <div id="bloc_principal" style="min-height: 600px; margin-bottom: 25px;">
  41. <header>
  42. <?php include ("../elements/navigation.php") ?>
  43.  
  44. </header>
  45. <div id="banniere_image"></div>
  46. <div class="bottom">
  47. <div class="col">
  48. <h1>Réintialiser mon mot de passe </h1>
  49. <form action="" method="POST">
  50.  
  51. <label for="">Mot de passe : </label>
  52. <input type="password" name="password" /><br/><br/>
  53.  
  54. <label for="">Confirmation du mot de passe : </label>
  55. <input type="password" name="password_confirm" /><br/><br/>
  56.  
  57.  
  58.  
  59. <button type="submit">Réinitaliser mon mot de passe</button>
  60.  
  61. </form>
  62. </div>
  63. <div class="col_deux">
  64. <?php include("../elements/espace_membre.php") ?>
  65. <?php include('../elements/discord.php') ?>
  66. </div>
  67.  
  68. </div>
  69. </div>
  70. </body>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement