SaeDEV2.2/php/inscription.php

94 lines
2.8 KiB
PHP
Raw Normal View History

<html lang="fr">
<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>
<body>
2024-06-10 19:29:21 +02:00
<?php
// Informations de connexion à la base de données
require_once 'common.php';
session_start();
if (!empty($_REQUEST['login']) && !empty($_REQUEST['password'])) {
$db = initDatabase();
$login = $_POST['login'];
$password = $_POST['password'];
$role = $_POST['role'];
$password_hash = password_hash($password, PASSWORD_DEFAULT);
$verif=mysqli_query($db,"SELECT * FROM user WHERE login = '$login' ");
$result="INSERT INTO user VALUES('$login','$password_hash','$role')";
if (mysqli_num_rows($verif) == 0) {
if (mysqli_query($db,$result)) {
header('Location: connexion.php');
exit();
}
else {
die("erreur");
}
}
else {
echo 'login déjà utilisé';
header('Location: inscription.php');
echo 'login déjà utilisé';
}
2024-06-10 19:29:21 +02:00
}
// Récupération des données du formulaire
?>
2024-06-10 19:29:21 +02:00
<div class="content_cours">
<header>
<nav>
<a href="../index.php" class="categorie">Page d'accueil</a>
</nav>
</header>
<h2>Inscription</h2> <br>
<form action="" method="post">
<label for="login">Login :</label><br>
<input type="text" id="login" name="login" value="<?php if (isset($_REQUEST['login'])) { echo $_REQUEST['login']; } ?>"><br>
<label for="password">Mot de passe :</label><br>
<input type="password" id="password" name="password" required placeholder="••••••••" value="<?php if (isset($_REQUEST['login'])) { echo $_REQUEST['login']; } ?>"><br>
<label for="role">Role:</label>
<select id="role" name="role" required>
<option value="spectator">Spectator</option>
<option value="athlete">Athlete</option>
<option value="organizer">Organizer</option>
</select><br><br>
<input type="submit" value="Se connecter">
</form>
</div>
2024-06-10 19:29:21 +02:00
<footer>
<div class="licence">
<p>Ces ressources sont publiées sous licence Creative Commons Attribution</p>
<a href="http://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank">
<img alt="Licence CC Attribution" src="../img/cc.png">
</a>
<p>
<strong>Site SAE 2.2 réalisé par : </strong>
<a href="mailto:rafael.ghouar-toussaint@etu.u-pec.fr">Rafaël Ghouar-Toussaint</a> -
<a href="mailto:alexis.hadjem-brancher@etu.u-pec.fr">Alexis Hadjem-Brancher</a> -
<a href="mailto:nicolas1.laurent@etu.u-pec.fr">Nicolas Laurent</a>
</p><br>
</footer>
</body>
</html>