Actualiser register.php
This commit is contained in:
18
register.php
18
register.php
@@ -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' => 'User'
|
'role' => ($username === 'admin') ? 'Admin' : '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");
|
||||||
@@ -35,13 +35,25 @@ include 'include/header.php';
|
|||||||
<p class="form-error"><?php echo htmlspecialchars($message); ?></p>
|
<p class="form-error"><?php echo htmlspecialchars($message); ?></p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<form method="POST" action="register.php">
|
<form method="POST" action="register.php">
|
||||||
<label for="username" class="sr-only">Nom d'utilisateur</label>
|
<label class="field-label" for="username">Nom d'utilisateur</label>
|
||||||
<input id="username" type="text" name="username" placeholder="Nom d'utilisateur" required>
|
<input id="username" type="text" name="username" placeholder="Nom d'utilisateur" required>
|
||||||
<label for="password" class="sr-only">Mot de passe</label>
|
|
||||||
|
<label class="field-label" for="password">Mot de passe</label>
|
||||||
|
<div class="password-wrapper">
|
||||||
<input id="password" type="password" name="password" placeholder="Mot de passe (6 car. min.)" required>
|
<input id="password" type="password" name="password" placeholder="Mot de passe (6 car. min.)" required>
|
||||||
|
<button type="button" class="toggle-password" onclick="togglePassword()">👁️</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<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>
|
||||||
|
function togglePassword() {
|
||||||
|
const input = document.getElementById('password');
|
||||||
|
input.type = input.type === 'password' ? 'text' : 'password';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<?php include 'include/footer.php'; ?>
|
<?php include 'include/footer.php'; ?>
|
||||||
Reference in New Issue
Block a user