Actualiser register.php

This commit is contained in:
2026-05-22 11:57:02 +00:00
parent cca989a9f1
commit e7b8d8515c

View File

@@ -18,7 +18,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$hash = password_hash($password, PASSWORD_DEFAULT); $hash = password_hash($password, PASSWORD_DEFAULT);
$users[$username] = [ $users[$username] = [
'password' => $hash, 'password' => $hash,
'role' => ($username === 'admin') ? 'Admin' : 'User' 'role' => 'User'
]; ];
file_put_contents($usersFile, json_encode($users, JSON_PRETTY_PRINT)); file_put_contents($usersFile, json_encode($users, JSON_PRETTY_PRINT));
header("Location: login.php?registered=1"); header("Location: login.php?registered=1");
@@ -29,7 +29,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
include 'include/header.php'; include 'include/header.php';
?> ?>
<div class="form-box"> <div class="form-box">
<h2>Créer un compte</h2> <h2>Créer un compte</h2>
<?php if ($message): ?> <?php if ($message): ?>
<p class="form-error"><?php echo htmlspecialchars($message); ?></p> <p class="form-error"><?php echo htmlspecialchars($message); ?></p>
@@ -47,13 +47,13 @@ include 'include/header.php';
<button type="submit">S'inscrire</button> <button type="submit">S'inscrire</button>
</form> </form>
<p class="form-link">Déjà un compte ? <a href="login.php">Se connecter</a></p> <p class="form-link">Déjà un compte ? <a href="login.php">Se connecter</a></p>
</div> </div>
<script> <script>
function togglePassword() { function togglePassword() {
const input = document.getElementById('password'); const input = document.getElementById('password');
input.type = input.type === 'password' ? 'text' : 'password'; input.type = input.type === 'password' ? 'text' : 'password';
} }
</script> </script>
<?php include 'include/footer.php'; ?> <?php include 'include/footer.php'; ?>