Skip to content

Commit

Permalink
add logout feature
Browse files Browse the repository at this point in the history
  • Loading branch information
creme332 committed Jan 18, 2024
1 parent c5c39f3 commit 20eeb81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/controllers/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Steamy\Core\Controller;
use Steamy\Model\User;

class Profile
{
use Controller;
Expand All @@ -16,6 +17,12 @@ public function index(): void
redirect('login');
}

// log out user if logout button clicked
if (isset($_POST['logout_submit'])) {
$_SESSION = array();
redirect('login');
}

// fetch user details from database
$current_user = new User();

Expand Down
10 changes: 6 additions & 4 deletions src/views/Profile.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<main class="container">
<h1>Your account</h1>
<h3>Personal details</h3>
<h2>Personal details</h2>
<form action="">
<label class="grid">
Name:
Expand All @@ -19,7 +19,7 @@
<input value="Mauritius" type="text" disabled>
</label>
</form>
<h2>Your orders</h2>
<h2>Orders summary</h2>
<table>
<tr>
Expand Down Expand Up @@ -79,7 +79,9 @@
</div>
</fieldset>
<button>Log out</button>
<button>Delete account</button>
<form method="post">
<button type="submit" name="logout_submit">Log out</button>
</form>
<button disabled>Delete account</button>
</main>

0 comments on commit 20eeb81

Please sign in to comment.