SaeDEV2.2/php/inscription.php

32 lines
780 B
PHP
Raw Permalink Normal View History

2024-06-10 19:29:21 +02:00
<?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);
2024-06-11 09:22:39 +02:00
$query_insert = "INSERT INTO user (login, mdp, Role) VALUES ('$login', '$password_hash','$role')";
2024-06-10 19:29:21 +02:00
if (mysqli_query($db, $query_insert)) {
echo "Inscription réussie !";
} else {
echo "Erreur lors de l'inscription : " . mysqli_error($db);
}
mysqli_close($db);
?>