From b1e87d06ab85d913202e3992cfc37bf86cc1a3e7 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Wed, 8 Apr 2026 10:50:41 +0200 Subject: [PATCH] Aggiunta UserID in sessione --- login.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/login.php b/login.php index ea2232d..c6e7a10 100644 --- a/login.php +++ b/login.php @@ -17,17 +17,18 @@ $email = $_POST['email']; $password = $_POST['password']; - $sql = "SELECT Name, Password, Role FROM Users WHERE Email = ?"; + $sql = "SELECT UserID, Name, Password, Role FROM Users WHERE Email = ?"; if ($stmt = $conn->prepare($sql)) { $stmt->bind_param("s", $email); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows > 0) { - $stmt->bind_result($name, $hashed_password, $role); + $stmt->bind_result($user_id, $name, $hashed_password, $role); $stmt->fetch(); if (password_verify($password, $hashed_password)) { + $_SESSION['id'] = $user_id; $_SESSION['user'] = $name; $_SESSION['role'] = $role; header('Location: index.php');