35 lines
946 B
PHP
35 lines
946 B
PHP
<?php
|
|
|
|
if (processForm()) {
|
|
checkUsernameFormat($_POST['new-username']);
|
|
|
|
$username = hashUsername($_POST['new-username']);
|
|
|
|
if (usernameExists($username) !== false)
|
|
output(403, 'Ce nom de compte est déjà utilisé.');
|
|
|
|
$stmt = DB->prepare('UPDATE users SET username = :username WHERE id = :id');
|
|
|
|
$stmt->bindValue(':id', $_SESSION['id']);
|
|
$stmt->bindValue(':username', $username);
|
|
|
|
$stmt->execute();
|
|
|
|
$_SESSION['display-username'] = htmlspecialchars($_POST['new-username']);
|
|
|
|
output(200, 'Identifiant changé.');
|
|
}
|
|
|
|
?>
|
|
|
|
<p>
|
|
Vous pouvez ici changer l'identifiant permettant d'accéder à votre compte Niver.
|
|
</p>
|
|
|
|
<form method="post">
|
|
<label for="new-username">Nouvel identifiant</label><br>
|
|
<input required="" autocomplete="new-username" minlength="1" maxlength="1024" pattern="<?= USERNAME_REGEX ?>" id="new-username" name="new-username" type="text" placeholder="<?= PLACEHOLDER_USERNAME ?>"><br>
|
|
|
|
<input type="submit">
|
|
</form>
|