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