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>";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Récupération des données du formulaire
|
|
||||||
$login = $_POST['login'];
|
$login = $_POST['login'];
|
||||||
$password = $_POST['password'];
|
$password = $_POST['password'];
|
||||||
$role = $_POST['role'];
|
$role = $_POST['role'];
|
||||||
|
|
||||||
|
|
||||||
/*$stmt = mysqli_prepare($db,
|
|
||||||
"INSERT INTO user (login, mdp)
|
|
||||||
VALUES (?,?)");*/
|
|
||||||
|
|
||||||
$password_hash = password_hash($password, PASSWORD_DEFAULT);
|
$password_hash = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
$query_insert = "INSERT INTO user (login, mdp, Role) VALUES ('$login', '$password_hash','$role')";
|
$verif=mysqli_query($db,"SELECT * FROM user WHERE login = '$login' ");
|
||||||
|
$result="INSERT INTO user VALUES('$login','$password_hash','$role')";
|
||||||
|
|
||||||
if (mysqli_query($db, $query_insert)) {
|
if (mysqli_num_rows($verif) == 0) {
|
||||||
echo "Inscription réussie !";
|
if (mysqli_query($db,$result)) {
|
||||||
} else {
|
|
||||||
echo "Erreur lors de l'inscription : " . mysqli_error($db);
|
header('Location: connexion.php');
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
mysqli_close($db);
|
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
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<div id="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>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user