Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_GET['id']) && isset($_GET['token'])){
- require 'base.php';
- require 'functions.php';
- $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)');
- $req->execute([$_GET['id'], $_GET['token']]);
- $user = $req->fetch();
- if($user){
- if(!empty($_POST)){
- if(!empty($_POST['password']) && $_POST['password'] == $_POST['password_confirm']){
- $password = password_hash($_POST['password'], PASSWORD_BCRYPT);
- $pdo->prepare('UPDATE users SET password = ?, reset_at = NULL, reset_token = NULL')->execute([$password]);
- session_start();
- $_SESSION['flash']['success'] = 'Votre mot de passe a bien été modifié';
- $_SESSION['auth'] = $user;
- header('Location: compte.php');
- exit();
- }
- }
- }else{
- session_start();
- $_SESSION['flash']['error'] = "Ce token n'est pas valide";
- header('Location: connexion.php');
- exit();
- }
- }else{
- header('Location: connexion.php');
- exit();
- }
- ?>
- <html>
- <head>
- <meta charset="utf-8" />
- <title>Mangas'Fan</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <link rel="icon" href="../images/favicon.png"/>
- <link rel="stylesheet" href="http://www.mangasfan.pe.hu/feuille.css" />
- </head>
- <body>
- <div id="bloc_principal" style="min-height: 600px; margin-bottom: 25px;">
- <header>
- <?php include ("../elements/navigation.php") ?>
- </header>
- <div id="banniere_image"></div>
- <div class="bottom">
- <div class="col">
- <h1>Réintialiser mon mot de passe </h1>
- <form action="" method="POST">
- <label for="">Mot de passe : </label>
- <input type="password" name="password" /><br/><br/>
- <label for="">Confirmation du mot de passe : </label>
- <input type="password" name="password_confirm" /><br/><br/>
- <button type="submit">Réinitaliser mon mot de passe</button>
- </form>
- </div>
- <div class="col_deux">
- <?php include("../elements/espace_membre.php") ?>
- <?php include('../elements/discord.php') ?>
- </div>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement