Aggiunta cognome in sessione

This commit is contained in:
2026-04-08 10:56:58 +02:00
parent 1239dc419e
commit a6d66a5253
5 changed files with 13 additions and 12 deletions
+3 -3
View File
@@ -25,16 +25,16 @@ if ($result === false) {
<div id="logo" style="font-size: 24px; font-weight: bold;"><a href="index.php"><img src="img/logo.png" alt="Logo TechStore" height="32px"></a></div>
<div>
<a href="cart.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer;">Carrello</button></a>
<?php if (isset($_SESSION['user'])): ?>
<?php if (isset($_SESSION['name'])): ?>
<a href="logout.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #dc3545; color: white; border: none; border-radius: 4px; cursor: pointer;">Logout</button></a>
<span style="margin-left: 10px;">Benvenuto, <?php echo htmlspecialchars($_SESSION['user']); ?></span>
<span style="margin-left: 10px;">Benvenuto, <?php echo htmlspecialchars($_SESSION['name']); ?></span>
<?php else: ?>
<a href="login.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">Accesso</button></a>
<?php endif; ?>
</div>
</header>
<?php if (isset($_SESSION['user'])): ?>
<?php if (isset($_SESSION['name'])): ?>
<div class="account-layout">
<div class="my-sidebar">
<ul>
+2 -2
View File
@@ -16,9 +16,9 @@ session_start();
<div id="logo" style="font-size: 24px; font-weight: bold;"><a href="index.php"><img src="img/logo.png" alt="Logo TechStore" height="32px"></a></div>
<div>
<a href="cart.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer;">Carrello</button></a>
<?php if (isset($_SESSION['user'])): ?>
<?php if (isset($_SESSION['name'])): ?>
<a href="logout.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #dc3545; color: white; border: none; border-radius: 4px; cursor: pointer;">Logout</button></a>
<span style="margin-left: 10px;">Benvenuto, <a href="account.php"><?php echo htmlspecialchars($_SESSION['user']); ?></a></span>
<span style="margin-left: 10px;">Benvenuto, <a href="account.php"><?php echo htmlspecialchars($_SESSION['name']); ?></a></span>
<?php else: ?>
<a href="login.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">Accesso</button></a>
<?php endif; ?>
+2 -2
View File
@@ -25,9 +25,9 @@ if ($result === false) {
<div id="logo"><img src="img/logo.png" alt="Logo TechStore" height="32px"></div>
<div>
<a href="cart.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer;">Carrello</button></a>
<?php if (isset($_SESSION['user'])): ?>
<?php if (isset($_SESSION['name'])): ?>
<a href="logout.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #dc3545; color: white; border: none; border-radius: 4px; cursor: pointer;">Logout</button></a>
<span style="margin-left: 10px;">Benvenuto, <a href="account.php"><?php echo htmlspecialchars($_SESSION['user']); ?></a></span>
<span style="margin-left: 10px;">Benvenuto, <a href="account.php"><?php echo htmlspecialchars($_SESSION['name']); ?></a></span>
<?php else: ?>
<a href="login.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">Accesso</button></a>
<?php endif; ?>
+4 -3
View File
@@ -17,19 +17,20 @@
$email = $_POST['email'];
$password = $_POST['password'];
$sql = "SELECT UserID, Name, Password, Role 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($user_id, $name, $hashed_password, $role);
$stmt->bind_result($user_id, $name, $surname, $hashed_password, $role);
$stmt->fetch();
if (password_verify($password, $hashed_password)) {
$_SESSION['id'] = $user_id;
$_SESSION['user'] = $name;
$_SESSION['name'] = $name;
$_SESSION['surname'] = $surname;
$_SESSION['role'] = $role;
header('Location: index.php');
exit();
+2 -2
View File
@@ -36,9 +36,9 @@ if ($stmt = $conn->prepare($sql)) {
<div id="logo" style="font-size: 24px; font-weight: bold;"><a href="index.php"><img src="img/logo.png" alt="Logo TechStore" height="32px"></a></div>
<div>
<a href=""><button style="margin-left: 10px; padding: 8px 16px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer;">Carrello</button></a>
<?php if (isset($_SESSION['user'])): ?>
<?php if (isset($_SESSION['name'])): ?>
<a href="logout.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #dc3545; color: white; border: none; border-radius: 4px; cursor: pointer;">Logout</button></a>
<span style="margin-left: 10px;">Benvenuto, <a href="account.php"><?php echo htmlspecialchars($_SESSION['user']); ?></a></span>
<span style="margin-left: 10px;">Benvenuto, <a href="account.php"><?php echo htmlspecialchars($_SESSION['name']); ?></a></span>
<?php else: ?>
<a href="login.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">Accesso</button></a>
<?php endif; ?>