prepare("SELECT M.nom, M.Password, M.droit_id, D.LibDroit, M.id FROM Membre M INNER JOIN Droit D ON M.droit_id = D.idDroit WHERE M.nom = :Login"); $stmt->bindParam(':Login', $Login, PDO::PARAM_STR); $stmt->execute(); $user = $stmt->fetch(PDO::FETCH_ASSOC); if ($user && password_verify($password, $user['Password'])) { $_SESSION['user'] = [ 'idD' => $user['droit_id'], 'idM' => $user['id'], 'Login' => $user['nom'], 'role' => $user['LibDroit'] ]; // Redirection selon le rôle if ($user['LibDroit'] === 'responsable') { $message = urlencode("Connexion réussie. Bienvenue responsable : " . htmlspecialchars($user['nom']) . "!"); header("Location: index.php?route=coucou&message=$message"); } elseif ($user['LibDroit'] === 'dev') { $message = urlencode(htmlspecialchars($user['nom']) ); header("location: index.php?route=coucou&message=$message"); } else { $_SESSION['erreur'] = "Rôle inconnu"; header("location:index.php?route=afficherFromCo"); exit(); } } else { $_SESSION['erreur'] = "Identifiants incorrects"; header("location: index.php?route=afficherFromCo"); exit(); } } catch (Exception $e) { $_SESSION['erreur'] = "Erreur : " . $e->getMessage(); header("location :index.php?route=afficherFromCo"); exit(); } } } } }