forked from ghouar-t/SaeDEV2.2
travail en colab avec alexis et nicolas sur un partage
This commit is contained in:
parent
aad22c9bc7
commit
f154a81961
@ -1,32 +1,75 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Informations de connexion à la base de données
|
// Informations de connexion à la base de données
|
||||||
$db = mysqli_connect("dwarves.iut-fbleau.fr","ghouar-t","Bases2023","ghouar-t");
|
require_once 'common.php';
|
||||||
if(!$db){
|
session_start();
|
||||||
die("Connexion BD impossible.");
|
if (!empty($_REQUEST['login']) && !empty($_REQUEST['password'])) {
|
||||||
}else{
|
$db = initDatabase();
|
||||||
echo "Connexion BD reussie ! <br>";
|
$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
|
// 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')";
|
<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>
|
||||||
|
|
||||||
if (mysqli_query($db, $query_insert)) {
|
<div id="content_cours">
|
||||||
echo "Inscription réussie !";
|
|
||||||
} else {
|
|
||||||
echo "Erreur lors de l'inscription : " . mysqli_error($db);
|
|
||||||
}
|
|
||||||
mysqli_close($db);
|
|
||||||
|
|
||||||
?>
|
<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>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user