Skip to content

Commit 779fbd1

Browse files
committed
logout
1 parent 231de05 commit 779fbd1

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

src/home.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
<?php
2-
session_start();
2+
session_start();
33

4-
// Controlla se l'utente è autenticato
5-
if (!isset($_SESSION['success'])) {
6-
header("Location: index.php");
7-
exit();
8-
}
9-
10-
// Recupera il nome utente dalla sessione
11-
$username = $_SESSION['username'];
4+
// Controlla se l'utente è autenticato
5+
if (!isset($_SESSION['success'])) {
6+
header("Location: index.php");
7+
exit();
8+
}
129
?>
1310

1411
<!DOCTYPE html>
@@ -27,10 +24,13 @@
2724
<body>
2825
<div class="login-container">
2926
<div class="login-box">
30-
<h1 class="text-center">Welcome, <?php echo $username?>!</h1>
31-
<div class="text-center mt-4">
27+
<h1 class="text-center">Welcome</h1>
28+
<div class="text-center mt-4 mb-2">
3229
<p>You have successfully logged in</p>
3330
</div>
31+
<div class="d-grid mt-4">
32+
<a href="logout.php" class="btn btn-danger btn-block">Logout</a>
33+
</div>
3434
</div>
3535
</div>
3636

src/index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
<label for="username">Username</label>
3333
<input type="text" class="form-control" name="username" placeholder="Enter username" autocomplete="off">
3434
</div>
35-
<div class="form-group mb-3">
35+
<div class="form-group mb-4">
3636
<label for="password">Password</label>
3737
<input type="password" class="form-control" name="password" placeholder="Enter password" autocomplete="off">
3838
</div>
39-
<div class="d-grid mt-3">
40-
<button type="submit" class="btn btn-primary btn-block">Login</button>
39+
<div class="d-grid mt-4">
40+
<button type="submit" class="btn btn-primary btn-block">Continue</button>
4141
</div>
4242
</form>
4343
</div>

src/logout.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
session_start();
3+
4+
session_destroy();
5+
6+
header("Location: index.php");
7+
exit();
8+
?>

0 commit comments

Comments
 (0)