From 8b37e33a9fd23205728fbf47981f6336a20f489b Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Fri, 10 Apr 2026 12:48:54 +0200 Subject: [PATCH] Implementazione pagina cambio password --- src/account.php | 4 +- src/account/passwordChange.php | 90 ++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 src/account/passwordChange.php diff --git a/src/account.php b/src/account.php index f664fa6..7d48394 100644 --- a/src/account.php +++ b/src/account.php @@ -49,8 +49,8 @@ if ($result === false) {

Account di

Nome completo:


- Modifica password - Elimina account + Modifica password + Elimina account

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