32 lines
780 B
PHP
32 lines
780 B
PHP
<?php
|
|
|
|
// Informations de connexion à la base de données
|
|
$db = mysqli_connect("dwarves.iut-fbleau.fr","ghouar-t","Bases2023","ghouar-t");
|
|
if(!$db){
|
|
die("Connexion BD impossible.");
|
|
}else{
|
|
echo "Connexion BD reussie ! <br>";
|
|
}
|
|
|
|
// 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')";
|
|
|
|
if (mysqli_query($db, $query_insert)) {
|
|
echo "Inscription réussie !";
|
|
} else {
|
|
echo "Erreur lors de l'inscription : " . mysqli_error($db);
|
|
}
|
|
mysqli_close($db);
|
|
|
|
?>
|