diff --git a/php/inscription.php b/php/inscription.php index d230215..496370d 100644 --- a/php/inscription.php +++ b/php/inscription.php @@ -1,32 +1,75 @@ "; +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é'; + } + } // Récupération des données du formulaire -$login = $_POST['login']; -$password = $_POST['password']; -$role = $_POST['role']; -/*$stmt = mysqli_prepare($db, -"INSERT INTO user (login, mdp) -VALUES (?,?)");*/ +?> -$password_hash = password_hash($password, PASSWORD_DEFAULT); -$query_insert = "INSERT INTO user (login, mdp, Role) VALUES ('$login', '$password_hash','$role')"; + + + + + + Inscription - Jeux Olympiques + + -if (mysqli_query($db, $query_insert)) { - echo "Inscription réussie !"; -} else { - echo "Erreur lors de l'inscription : " . mysqli_error($db); -} -mysqli_close($db); +
-?> \ No newline at end of file +
+ +
+ + +

Inscription


+ +
+
+
+
+
+ +

+ +
+ + + \ No newline at end of file