From 1eff402091f33fd8cf523216b3e50e63bd7f8452 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Tue, 7 Apr 2026 23:03:58 +0200 Subject: [PATCH 01/11] Creazione pagina account personale --- account.php | 41 +++++++++++++++++++++++++++++++++++++++++ cart.php | 2 +- index.php | 2 +- product.php | 2 +- 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 account.php diff --git a/account.php b/account.php new file mode 100644 index 0000000..29c8647 --- /dev/null +++ b/account.php @@ -0,0 +1,41 @@ +query($sql); + +if ($result === false) { + die("Errore nella query: " . $conn->error); +} +?> + + + + + + + Il mio account - TechStore + + + + +
+ +
+ + + + Benvenuto, + + + +
+
+ + + + close(); ?> + + diff --git a/cart.php b/cart.php index 24732c2..eb6fd1d 100644 --- a/cart.php +++ b/cart.php @@ -18,7 +18,7 @@ session_start(); - Benvenuto, + Benvenuto, diff --git a/index.php b/index.php index af02b1d..b6c7007 100644 --- a/index.php +++ b/index.php @@ -27,7 +27,7 @@ if ($result === false) { - Benvenuto, + Benvenuto, diff --git a/product.php b/product.php index 80675ba..7205975 100644 --- a/product.php +++ b/product.php @@ -38,7 +38,7 @@ if ($stmt = $conn->prepare($sql)) { - Benvenuto, + Benvenuto, From 8a087a0924905c1537bb03e15372d1f0401de31b Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Wed, 8 Apr 2026 10:18:45 +0200 Subject: [PATCH 02/11] Aggiunta campo Role in tabella Users --- base_db.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/base_db.sql b/base_db.sql index 9fe877e..94f44a0 100644 --- a/base_db.sql +++ b/base_db.sql @@ -8,7 +8,8 @@ CREATE TABLE Users( Name VARCHAR(32), Surname VARCHAR(32), Email VARCHAR(256), - Password VARCHAR(255) + Password VARCHAR(255), + Role VARCHAR(8) DEFAULT 'user' ); CREATE TABLE Categories( From 2886c19b315089060a4fbc1e6c50839ff2d9b953 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Wed, 8 Apr 2026 10:28:29 +0200 Subject: [PATCH 03/11] Implementazione base pagina account --- account.php | 16 +++++++++++++- assets/style.css | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/account.php b/account.php index 29c8647..bfaffe2 100644 --- a/account.php +++ b/account.php @@ -34,7 +34,21 @@ if ($result === false) { - + + + + + close(); ?> diff --git a/assets/style.css b/assets/style.css index e431e8d..8418c1e 100644 --- a/assets/style.css +++ b/assets/style.css @@ -208,4 +208,60 @@ form button:hover { } .checkout-btn:hover { background-color: #218838; +} + +/* Layout pagina account */ +.account-layout { + display: flex; + flex-wrap: wrap; + gap: 20px; + max-width: 1100px; + margin: 20px auto; + padding: 0 20px; + box-sizing: border-box; +} + +.my-sidebar { + flex: 0 0 240px; + border: 1px solid #ddd; + border-radius: 8px; + background-color: #fff; + padding: 20px; +} + +.my-sidebar ul { + list-style: none; + margin: 0; + padding: 0; +} + +.my-sidebar li { + margin-bottom: 12px; +} + +.my-sidebar a { + color: #007bff; + text-decoration: none; +} + +.my-sidebar a:hover { + text-decoration: underline; +} + +.my-container { + flex: 1 1 580px; + border: 1px solid #ddd; + border-radius: 8px; + background-color: #fff; + padding: 20px; +} + +@media (max-width: 768px) { + .account-layout { + flex-direction: column; + } + .my-sidebar, + .my-container { + flex: 1 1 100%; + } } \ No newline at end of file From 06b7523541a032d5fab02fc3e665fbfcbfae01ca Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Wed, 8 Apr 2026 10:32:53 +0200 Subject: [PATCH 04/11] Aggiunta ruolo utente in sessione al login --- login.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/login.php b/login.php index ba7807f..ea2232d 100644 --- a/login.php +++ b/login.php @@ -17,18 +17,19 @@ $email = $_POST['email']; $password = $_POST['password']; - $sql = "SELECT Name, Password FROM Users WHERE Email = ?"; + $sql = "SELECT 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); + $stmt->bind_result($name, $hashed_password, $role); $stmt->fetch(); if (password_verify($password, $hashed_password)) { $_SESSION['user'] = $name; + $_SESSION['role'] = $role; header('Location: index.php'); exit(); } else { From c0201994b2784f34e559cf7036c832be596239ae Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Wed, 8 Apr 2026 10:37:35 +0200 Subject: [PATCH 05/11] Aggiustamento layout pagina account + aggiunto pulsante elimina account --- account.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/account.php b/account.php index bfaffe2..224b4f3 100644 --- a/account.php +++ b/account.php @@ -42,8 +42,9 @@ if ($result === false) {
-

Il mio account

-

Nome utente:

+

Account di

+ Elimina account +

From 0956cf9a80c7f9c1645a354eb30d3ee683574a3b Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Wed, 8 Apr 2026 10:43:18 +0200 Subject: [PATCH 06/11] Aggiunta "badge" admin in pagina account --- account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account.php b/account.php index 224b4f3..9cea827 100644 --- a/account.php +++ b/account.php @@ -42,7 +42,7 @@ if ($result === false) {
-

Account di

+

Account di

Elimina account

From b1e87d06ab85d913202e3992cfc37bf86cc1a3e7 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Wed, 8 Apr 2026 10:50:41 +0200 Subject: [PATCH 07/11] 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'); From 924a100518f5286bebfbfbc7b7fcea984cbf1800 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Wed, 8 Apr 2026 10:51:31 +0200 Subject: [PATCH 08/11] Inserimento admin di esempio in DB base --- base_db.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base_db.sql b/base_db.sql index 94f44a0..850a06f 100644 --- a/base_db.sql +++ b/base_db.sql @@ -54,4 +54,8 @@ INSERT INTO Categories(Name) VALUES INSERT INTO Products(ProductName,Description,CategoryID,Price,ImagePath,StockQuantity) VALUES ('Yealink T31P',"Telefono IP con PoE, Ethernet a 100M, 2 linee",3,'51.21','example/t31p.jpg',104), ('Lenovo ThinkCentre M920q','Mini PC (Ricondizionato) Intel Core i5, 512GB SSD, 16GB RAM, Windows 11 Pro',1,'299','example/tcM920q.jpg',69), -('Mercusys MS116GS Switch 16 Porte','Switch Gigabit 16 Porte, Montaggio Desktop o Rack, Plug & Play, Priorità del Traffico, Prevenzione Loop, Modalità di Isolamento, Funzionamento Silenzioso, Case in Metallo',2,'44.99','example/mercusysMS116GS.jpg',727); \ No newline at end of file +('Mercusys MS116GS Switch 16 Porte','Switch Gigabit 16 Porte, Montaggio Desktop o Rack, Plug & Play, Priorità del Traffico, Prevenzione Loop, Modalità di Isolamento, Funzionamento Silenzioso, Case in Metallo',2,'44.99','example/mercusysMS116GS.jpg',727); + +-- Inserimento utente admin di base (password = changeme) +INSERT INTO Users (Name,Surname,Email,Password,Role) VALUES +('Ellen', 'Joe', 'admin@example.com', '$2y$12$zEXyLRdKvvvoH4/zuIuwYuQLA5GwsvZw2usIhxxbYyw4.uoeghe4m', 'admin'); \ No newline at end of file From 1239dc419e8b059a0d92c65c3b7616aaebbc8a1b Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Wed, 8 Apr 2026 10:52:02 +0200 Subject: [PATCH 09/11] Aggiunta link pagina ordini (ancora WIP) --- account.php | 1 + 1 file changed, 1 insertion(+) diff --git a/account.php b/account.php index 9cea827..ee0fad8 100644 --- a/account.php +++ b/account.php @@ -39,6 +39,7 @@ if ($result === false) {
From a6d66a5253f18a47f95cc337b9f3489a5e81081a Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Wed, 8 Apr 2026 10:56:58 +0200 Subject: [PATCH 10/11] Aggiunta cognome in sessione --- account.php | 6 +++--- cart.php | 4 ++-- index.php | 4 ++-- login.php | 7 ++++--- product.php | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/account.php b/account.php index ee0fad8..39c4bea 100644 --- a/account.php +++ b/account.php @@ -25,16 +25,16 @@ if ($result === false) {
- + - Benvenuto, + Benvenuto,
- +