Travail
This commit is contained in:
55
connexion/actionInscription.php
Normal file
55
connexion/actionInscription.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
require_once 'lib/common.php';
|
||||
session_start();
|
||||
|
||||
|
||||
$conn = initDatabase();
|
||||
|
||||
if (!$conn) {
|
||||
die("Erreur de connexion : " . mysqli_connect_error());
|
||||
}
|
||||
|
||||
$login = isset($_POST['login']) ? $_POST['login'] : '';
|
||||
$email = isset($_POST['email']) ? $_POST['email'] : '';
|
||||
$mdp = isset($_POST['mdp']) ? $_POST['mdp'] : '';
|
||||
|
||||
|
||||
if (empty($login) || empty($email) || empty($mdp)) {
|
||||
echo "<script>alert('Tous les champs doivent être remplis.'); window.location.href ='./notif.php';</script>";
|
||||
exit();
|
||||
}
|
||||
|
||||
$mdp_hash = password_hash($mdp, PASSWORD_DEFAULT);
|
||||
|
||||
|
||||
$sql_verif = "SELECT login FROM UTILISATEUR WHERE login = ?";
|
||||
$stmt_verif = mysqli_prepare($conn, $sql_verif);
|
||||
mysqli_stmt_bind_param($stmt_verif, "s", $login);
|
||||
mysqli_stmt_execute($stmt_verif);
|
||||
mysqli_stmt_store_result($stmt_verif);
|
||||
|
||||
if (mysqli_stmt_num_rows($stmt_verif) > 0) {
|
||||
echo "<script>alert('Ce login est déjà utilisé. Veuillez en choisir un autre.'); window.location.href ='./notif.php';</script>";
|
||||
mysqli_stmt_close($stmt_verif);
|
||||
mysqli_close($conn);
|
||||
exit();
|
||||
}
|
||||
mysqli_stmt_close($stmt_verif);
|
||||
|
||||
|
||||
$sql = "INSERT INTO UTILISATEUR (login, email, mdp) VALUES (?, ?, ?)";
|
||||
$stmt = mysqli_prepare($conn, $sql);
|
||||
mysqli_stmt_bind_param($stmt, "sss", $login, $email, $mdp_hash);
|
||||
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
|
||||
$_SESSION['login'] = $login;
|
||||
header('Location: actionLogin.php');
|
||||
exit();
|
||||
} else {
|
||||
echo "Erreur lors de l'inscription : " . mysqli_error($conn);
|
||||
}
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
36
connexion/actionLogin.php
Normal file
36
connexion/actionLogin.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
$conn = mysqli_connect("dwarves.iut-fbleau.fr", "bounnilo","YOYOYO","bounnilo");
|
||||
|
||||
if(!$conn) {
|
||||
die("Erreur de connexion :" . mysqli_connect_error());
|
||||
}
|
||||
|
||||
|
||||
$login = $_POST['login'];
|
||||
$mdp = $_POST['mdp'];
|
||||
|
||||
|
||||
$sql = "SELECT mdp , role FROM UTILISATEUR WHERE login =?";
|
||||
$stmt = mysqli_prepare($conn, $sql);
|
||||
|
||||
mysqli_stmt_bind_param($stmt, "s", $login);
|
||||
mysqli_stmt_execute($stmt);
|
||||
mysqli_stmt_bind_result($stmt,$mdp_hash, $role );
|
||||
|
||||
|
||||
if (mysqli_stmt_fetch($stmt)) {
|
||||
if(password_verify($mdp, $mdp_hash)){
|
||||
$_SESSION['login'] = $login;
|
||||
$_SESSION['role'] = $role;
|
||||
header('location:./Page-acc.php');
|
||||
}else{
|
||||
echo "<script>alert('Échec de l\\'authentification : mot de passe incorrect.'); window.location.href ='./login.html'; </script>";
|
||||
}
|
||||
} else {
|
||||
echo "<script>alert('Échec de l\\'authentification : identifiant incorrect.'); window.location.href ='./login.html'; </script>";
|
||||
}
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
32
connexion/inscription.html
Normal file
32
connexion/inscription.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Inscription</title>
|
||||
<link rel="stylesheet" href="login.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="login-container">
|
||||
<h2>Inscription</h2>
|
||||
<form action="actionInscription.php" method="post">
|
||||
<label for="login">Login :</label>
|
||||
<input type="text" name="login" required><br><br>
|
||||
|
||||
<label for="email">Adresse mail :</label>
|
||||
<input type="email" name="email" id="email" required> <br><br>
|
||||
|
||||
<label for="mdp">Mot de passe :</label>
|
||||
<input type="password" name="mdp" required><br><br>
|
||||
|
||||
<input type="submit" value="S'inscrire">
|
||||
</form>
|
||||
<p> Deja un compte ?
|
||||
<a href="login.html" class="link"> Connectez vous !</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="Page-acc.php" class="link"> Retour a l'accueil</a>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
56
connexion/login.css
Normal file
56
connexion/login.css
Normal file
@@ -0,0 +1,56 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: rgb(255, 79, 167);
|
||||
font-family: Arial, sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
width: 320px;
|
||||
padding: 30px;
|
||||
background-color: #f8bbd0;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
color: #880e4f;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
input[type="text"],
|
||||
input[type="password"],
|
||||
input[type="email"] {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 8px 0;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
width: 100%;
|
||||
background-color: #880e4f;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input[type="submit"]:hover{
|
||||
background-color:#ad1457;
|
||||
}
|
||||
29
connexion/login.html
Normal file
29
connexion/login.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Connexion</title>
|
||||
<link rel="stylesheet" href="login.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-container">
|
||||
<h2>Connexion</h2>
|
||||
<form action="actionLogin.php" method="post">
|
||||
<label for="login">Login :</label>
|
||||
<input type="text" name="login" required><br><br>
|
||||
|
||||
<label for="mdp">Mot de passe :</label>
|
||||
<input type="password" name="mdp" required><br><br>
|
||||
|
||||
<input type="submit" value="Se connecter">
|
||||
</form>
|
||||
<p>Pas encore de compte ?
|
||||
<a href="inscription.html" class="link"> Creez-en un !</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="Page-acc.html" class="link"> Retour a l'accueil</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user