-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.php
More file actions
61 lines (53 loc) · 1.82 KB
/
Copy pathheader.php
File metadata and controls
61 lines (53 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
$is_logged_in = isset($_SESSION['username']);
$userType = $is_logged_in ? $_SESSION['userType'] : null;
// Logout functionality
if (isset($_GET['logout'])) {
session_destroy();
header("Location: index.php");
exit();
}
?>
<header class="header">
<div class="logo">
<a href="index.php"><i class="fa-solid fa-book"></i> Knowledge Nest</a>
</div>
<nav class="nav-bar">
<ul class="nav__links">
<li><a href="index.php">Home</a></li>
<li><a href="#CSection">Contact</a></li>
<li><a href="books.php">Books</a></li>
<?php if ($userType === 'admin') {?>
<li><a href="borrowBook.php">Borrow</a></li>
<li><a href="reservation.php">Reservation</a></li>
<?php }?>
<?php if ($is_logged_in): ?>
<?php if ($userType === 'user'): ?>
<li><a href="myAccount.php">My Account</a></li>
<?php elseif ($userType === 'admin'): ?>
<li><a href="dashboard.php">Admin Dashboard</a></li>
<?php endif; ?>
<?php endif; ?>
</ul>
</nav>
<div class="login">
<?php if ($is_logged_in): ?>
<form method="GET" action="index.php">
<button type="submit" name="logout">
<i class="fa-solid fa-sign-out-alt"></i><b class="logout-text">Logout</b>
</button>
</form>
<?php else: ?>
<a href="login.php" class="login-icon">
<button><i class="fa-solid fa-user"></i><b class="login-text">Login</b></button>
</a>
<?php endif; ?>
</div>
<div class="toggle-btn">
<i class="fa-solid fa-bars"></i>
</div>
</div>
</header>