2024-06-14 18:42:40 +02:00
|
|
|
<html lang="fr" >
|
2024-06-13 20:17:56 +02:00
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<link rel="icon" href="../img/jo2024.jpg" >
|
|
|
|
<link rel="stylesheet" href="../css/style.css">
|
|
|
|
<title>Inscription - Jeux Olympiques</title>
|
|
|
|
</head>
|
2024-06-14 18:42:40 +02:00
|
|
|
<body >
|
2024-06-13 20:17:56 +02:00
|
|
|
|
|
|
|
|
2024-06-10 19:29:21 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Informations de connexion à la base de données
|
2024-06-13 18:06:02 +02:00
|
|
|
require_once 'common.php';
|
|
|
|
session_start();
|
|
|
|
if (!empty($_REQUEST['login']) && !empty($_REQUEST['password'])) {
|
|
|
|
$db = initDatabase();
|
|
|
|
$login = $_POST['login'];
|
|
|
|
$password = $_POST['password'];
|
|
|
|
$role = $_POST['role'];
|
2024-06-14 18:42:40 +02:00
|
|
|
$mail = $_POST['mail'];
|
2024-06-13 18:06:02 +02:00
|
|
|
$password_hash = password_hash($password, PASSWORD_DEFAULT);
|
|
|
|
|
|
|
|
$verif=mysqli_query($db,"SELECT * FROM user WHERE login = '$login' ");
|
2024-06-14 18:42:40 +02:00
|
|
|
$verif2=mysqli_query($db,"SELECT * FROM user WHERE mail = '$mail' ");
|
|
|
|
$result="INSERT INTO user VALUES('$login','$mail','$password_hash','$role')";
|
2024-06-13 18:06:02 +02:00
|
|
|
|
|
|
|
if (mysqli_num_rows($verif) == 0) {
|
2024-06-14 18:42:40 +02:00
|
|
|
if (mysqli_num_rows($verif2) == 0) {
|
|
|
|
if (mysqli_query($db,$result)) {
|
2024-06-13 18:06:02 +02:00
|
|
|
|
2024-06-14 18:42:40 +02:00
|
|
|
header('Location: connexion.php');
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
die("erreur");
|
|
|
|
}
|
2024-06-13 18:06:02 +02:00
|
|
|
}
|
|
|
|
else {
|
2024-06-14 18:42:40 +02:00
|
|
|
$error_verif2 = "cette adresse mail est déjà utilisé";
|
2024-06-13 18:06:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2024-06-14 18:42:40 +02:00
|
|
|
$error_verif = "ce login est déjà utilisé";
|
|
|
|
|
|
|
|
|
2024-06-13 18:06:02 +02:00
|
|
|
}
|
|
|
|
|
2024-06-10 19:29:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Récupération des données du formulaire
|
|
|
|
|
|
|
|
|
2024-06-13 18:06:02 +02:00
|
|
|
?>
|
2024-06-10 19:29:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2024-06-13 18:06:02 +02:00
|
|
|
|
|
|
|
<header>
|
2024-06-14 18:42:40 +02:00
|
|
|
<h1 class='Hello'> Page d'inscription </h1>
|
|
|
|
<nav>
|
2024-06-13 18:06:02 +02:00
|
|
|
<a href="../index.php" class="categorie">Page d'accueil</a>
|
2024-06-14 18:42:40 +02:00
|
|
|
|
2024-06-13 18:06:02 +02:00
|
|
|
</nav>
|
|
|
|
</header>
|
|
|
|
|
2024-06-14 18:42:40 +02:00
|
|
|
<div class="inscription" id="inscription">
|
2024-06-13 20:43:08 +02:00
|
|
|
|
|
|
|
|
2024-06-14 18:42:40 +02:00
|
|
|
<u><i><h2>Inscription</h2></i></u> <br>
|
2024-06-13 18:06:02 +02:00
|
|
|
|
|
|
|
<form action="" method="post">
|
|
|
|
<label for="login">Login :</label><br>
|
2024-06-14 18:42:40 +02:00
|
|
|
<input type="text" id="login" name="login" value="<?php if (isset($_REQUEST['login'])) { echo $_REQUEST['login']; } ?>" ><br>
|
|
|
|
<?php if (isset($error_verif)) {echo "<div class='error-message'>$error_verif</div>";} ?>
|
|
|
|
<br><br><label for="mail">Adresse mail :</label><br>
|
|
|
|
<input type="email" id="mail" name="mail" placeholder="username@example.com" value="<?php if (isset($_REQUEST['mail'])) { echo $_REQUEST['mail']; } ?>" required><br>
|
|
|
|
<?php if (isset($error_verif2)) {echo "<div class='error-message'>$error_verif2</div>";} ?>
|
|
|
|
|
|
|
|
<br><br><label for="password">Mot de passe :</label><br>
|
|
|
|
<input type="password" id="password" name="password" placeholder="••••••••" value="<?php if (isset($_REQUEST['password'])) { echo $_REQUEST['password']; } ?>" required><br>
|
|
|
|
|
|
|
|
|
|
|
|
<br><br><label for="role">Role :</label><br>
|
2024-06-13 18:06:02 +02:00
|
|
|
<select id="role" name="role" required>
|
2024-06-14 18:42:40 +02:00
|
|
|
<option value="">-- Please choose an option --</option>
|
|
|
|
<option value="spectator">Spectator</option>
|
2024-06-13 18:06:02 +02:00
|
|
|
<option value="athlete">Athlete</option>
|
|
|
|
<option value="organizer">Organizer</option>
|
|
|
|
</select><br><br>
|
2024-06-14 18:42:40 +02:00
|
|
|
<br><button type="submit" class="submit">Créer une compte </button>
|
2024-06-13 18:06:02 +02:00
|
|
|
</form>
|
2024-06-13 20:17:56 +02:00
|
|
|
|
2024-06-14 18:42:40 +02:00
|
|
|
<p class="compteUser">Vous possédez déjà un compte ? <br><a href="connexion.php">Connectez-vous !</a></p>
|
|
|
|
</div>
|
2024-06-10 19:29:21 +02:00
|
|
|
|
2024-06-13 19:50:01 +02:00
|
|
|
<footer>
|
2024-06-14 18:42:40 +02:00
|
|
|
<?php require_once('footer.php'); ?>
|
2024-06-13 19:50:01 +02:00
|
|
|
</footer>
|
|
|
|
|
2024-06-13 18:06:02 +02:00
|
|
|
</body>
|
|
|
|
</html>
|