intranet-apei/createPassword.php

95 lines
No EOL
2.5 KiB
PHP

<?php
include("./Assets/functions.php");
$config = json_decode(file_get_contents("./Assets/config.json"), true);
$bdd = connectBDD("localhost", $config["BDD_USER"], $config["BDD_PASSWD"], $config["BDD_NAME"]);
if (isset($_POST['password1'])) {
if ($_POST['password1'] == $_POST['password2']) {
$user = getUserFromCode($bdd, $_POST['code']);
updateUserPassword($bdd, $user, hash('sha256', $_POST['password1']));
header('location: index.php');
exit;
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Créer mon mot de passe</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
background: #f5f7fa;
}
.card {
border-radius: 15px;
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}
.title {
font-weight: 600;
}
</style>
</head>
<body class="d-flex align-items-center justify-content-center vh-100">
<div class="container" style="max-width:500px;">
<div class="card p-4">
<h1 class="h4 text-center mb-4 title">
Créer mon mot de passe
</h1>
<form method="post">
<div class="mb-3">
<label for="password1" class="form-label">
Nouveau mot de passe
</label>
<input
type="password"
class="form-control"
name="password1"
id="password1"
required>
</div>
<div class="mb-3">
<label for="password2" class="form-label">
Confirmer le mot de passe
</label>
<input
type="password"
class="form-control"
name="password2"
id="password2"
required>
</div>
<input type="hidden" name="code" value="<?= htmlspecialchars($_GET['code']) ?>">
<div class="d-grid">
<button type="submit" class="btn btn-primary">
Créer mon mot de passe
</button>
</div>
</form>
</div>
</div>
</body>
</html>