From 22e1ba32453b7cf6f93bef92dd0672f2b2759f19 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Wed, 1 Apr 2026 11:18:58 +0200 Subject: [PATCH] Implementata logica sessioni --- index.php | 8 +++++++- login.php | 37 +++++++++++++++++++++++++++++++++++++ logout.php | 6 ++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 logout.php diff --git a/index.php b/index.php index b36b436..8ca89a9 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,5 @@ TechStore
- + + Benvenuto, + + + +
diff --git a/login.php b/login.php index 9a1883c..0bef6fb 100644 --- a/login.php +++ b/login.php @@ -7,6 +7,43 @@ + prepare($sql)) { + $stmt->bind_param("s", $email); + $stmt->execute(); + $stmt->store_result(); + + if ($stmt->num_rows > 0) { + $stmt->bind_result($name, $hashed_password); + $stmt->fetch(); + + if (password_verify($password, $hashed_password)) { + $_SESSION['user'] = $name; + header('Location: index.php'); + exit(); + } else { + $error = 'Credenziali errate.'; + } + } else { + $error = 'Credenziali errate.'; + } + + $stmt->close(); + } else { + $error = 'Errore nel database.'; + } + } + ?>

Login

diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..2ac2507 --- /dev/null +++ b/logout.php @@ -0,0 +1,6 @@ + \ No newline at end of file