diff --git a/.gitignore b/.gitignore index 1a806e8..4e5364a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -img/* -!img/example/ -!img/logo.png \ No newline at end of file +src/img/* +!src/img/example/ +!src/img/logo.png \ No newline at end of file diff --git a/base_db.sql b/assets/db/base_db.sql similarity index 100% rename from base_db.sql rename to assets/db/base_db.sql diff --git a/src/account.php b/src/account.php index eca6fcb..7d48394 100644 --- a/src/account.php +++ b/src/account.php @@ -49,7 +49,8 @@ if ($result === false) {

Account di

Nome completo:


- Elimina account + Modifica password + Elimina account

diff --git a/src/account/delete.php b/src/account/delete.php new file mode 100644 index 0000000..e085c89 --- /dev/null +++ b/src/account/delete.php @@ -0,0 +1,92 @@ + + + + + + Elimina Account - TechStore + + + + prepare($sql)) { + $stmt->bind_param("i", $_SESSION['id']); + $stmt->execute(); + $stmt->bind_result($hashed_password); + $stmt->fetch(); + $stmt->close(); + + if (!password_verify($current_password, $hashed_password)) { + $error = 'La password non è corretta.'; + } else { + // Elimina gli ordini associati all'utente + $sql_delete_order_items = "DELETE oi FROM OrderItems oi JOIN Orders o ON oi.OrderID = o.OrderID WHERE o.UserID = ?"; + $stmt_delete_order_items = $conn->prepare($sql_delete_order_items); + $stmt_delete_order_items->bind_param("i", $_SESSION['id']); + $stmt_delete_order_items->execute(); + $stmt_delete_order_items->close(); + + $sql_delete_orders = "DELETE FROM Orders WHERE UserID = ?"; + $stmt_delete_orders = $conn->prepare($sql_delete_orders); + $stmt_delete_orders->bind_param("i", $_SESSION['id']); + $stmt_delete_orders->execute(); + $stmt_delete_orders->close(); + + $sql_delete_user = "DELETE FROM Users WHERE UserID = ?"; + $stmt_delete_user = $conn->prepare($sql_delete_user); + $stmt_delete_user->bind_param("i", $_SESSION['id']); + $stmt_delete_user->execute(); + $stmt_delete_user->close(); + + session_unset(); + session_destroy(); + + $message = 'Il tuo account è stato eliminato insieme a tutti i tuoi ordini.'; + } + } else { + $error = 'Errore nel database.'; + } + } + } + ?> + +
+

Elimina Account

+

Questa operazione cancellerà il tuo account e tutti gli ordini associati. Inserisci la tua password per confermare.

+ + +

+ +

+ + +

+ +

+ + + +
+ + +

Annulla e torna al mio account

+
+ + \ No newline at end of file diff --git a/src/account/passwordChange.php b/src/account/passwordChange.php new file mode 100644 index 0000000..ac49b8b --- /dev/null +++ b/src/account/passwordChange.php @@ -0,0 +1,90 @@ + + + + + + Cambio Password - TechStore + + + + prepare($sql)) { + $stmt->bind_param("i", $_SESSION['id']); + $stmt->execute(); + $stmt->bind_result($hashed_password); + $stmt->fetch(); + $stmt->close(); + + if (!password_verify($current_password, $hashed_password)) { + $error = 'La password corrente non è corretta.'; + } else { + $new_hashed = password_hash($new_password, PASSWORD_DEFAULT); + $sql_update = "UPDATE Users SET Password = ? WHERE UserID = ?"; + if ($stmt_update = $conn->prepare($sql_update)) { + $stmt_update->bind_param("si", $new_hashed, $_SESSION['id']); + $stmt_update->execute(); + $stmt_update->close(); + + $message = 'Password aggiornata con successo.'; + } else { + $error = 'Errore durante l\'aggiornamento della password.'; + } + } + } else { + $error = 'Errore nel database.'; + } + } + } + ?> + +
+

Cambio Password

+ +

+ +

+ + +

+ +

+ + + +
+ + +
+ + +
+ + +

Torna al mio account

+
+ + \ No newline at end of file