diff --git a/account.php b/account.php new file mode 100644 index 0000000..5acaa4d --- /dev/null +++ b/account.php @@ -0,0 +1,59 @@ +query($sql); + +if ($result === false) { + die("Errore nella query: " . $conn->error); +} +?> + + + + + + + Il mio account - TechStore + + + + +
+ +
+ + + + Benvenuto, + + + +
+
+ + +
+
+ +
+
+

Account di

+

Nome completo:

+
+ Elimina account +

+
+
+ + + + + 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 diff --git a/base_db.sql b/base_db.sql index 9fe877e..850a06f 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( @@ -53,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 diff --git a/cart.php b/cart.php index 24732c2..4810016 100644 --- a/cart.php +++ b/cart.php @@ -16,9 +16,9 @@ session_start();
- + - Benvenuto, + Benvenuto, diff --git a/index.php b/index.php index af02b1d..c44cc25 100644 --- a/index.php +++ b/index.php @@ -25,9 +25,9 @@ if ($result === false) {
- + - Benvenuto, + Benvenuto, diff --git a/login.php b/login.php index ba7807f..61b34e2 100644 --- a/login.php +++ b/login.php @@ -17,18 +17,21 @@ $email = $_POST['email']; $password = $_POST['password']; - $sql = "SELECT Name, Password FROM Users WHERE Email = ?"; + $sql = "SELECT UserID, Name, Surname, 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($user_id, $name, $surname, $hashed_password, $role); $stmt->fetch(); if (password_verify($password, $hashed_password)) { - $_SESSION['user'] = $name; + $_SESSION['id'] = $user_id; + $_SESSION['name'] = $name; + $_SESSION['surname'] = $surname; + $_SESSION['role'] = $role; header('Location: index.php'); exit(); } else { diff --git a/product.php b/product.php index 80675ba..6d4d764 100644 --- a/product.php +++ b/product.php @@ -36,9 +36,9 @@ if ($stmt = $conn->prepare($sql)) {
- + - Benvenuto, + Benvenuto,