<?php
SESSION_START();
print_r($_SESSION);
$count_tab = 0;
if (isset($_GET['adresse_mail']) && isset($_GET['token'])) {
require 'connexion_base_de_donnees.php';
$date = date('y/m/d H:i:s');
$req = $pdo->prepare('SELECT * FROM infosdesclients WHERE adresse_mail=? AND forgot_mdp=? AND date_token> DATE_SUB(date_token, INTERVAL 30 MINUTE)');
$req->execute([$_GET['adresse_mail'], $_GET['token']]);
$tab = $req->FETCHALL();
$count_tab = count($tab);
} else {
header('location: index.php');
die();
}
if (isset($_POST['valider']) and $count_tab > 0) {
if (!empty($_POST['nouveau_mot_de_passe']) && $_POST['nouveau_mot_de_passe'] == $_POST['confirmation_nouveau_mot_de_passe']) {
$nouveau_mot_de_passe = $_POST['nouveau_mot_de_passe'];
$pdo->prepare('UPDATE infosdesclients SET mot_de_passe = ?');
$pdo->execute([$nouveau_mot_de_passe]);
$_SESSION['authentification'] = $tab;
header('location: page_de_jeu.php');
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="page_principal_de_jeu.css">
<title>Konamicash</title>
</head>
<body>
<form action="" method="POST">
<div class="form-group">
<label for="">Nouveau mot de passe</label>
<input type="password" name="nouveau_mot_de_passe" class="" />
</div>
<div class="form-group">
<label for="">confirmation_nouveau_mot_de_passe</label>
<input type="password" name="confirmation_nouveau_mot_de_passe" class="" />
</div>
<button type="submit" name="valider">valider </button>
</form>
</body>
</html>