-
Notifications
You must be signed in to change notification settings - Fork 0
/
navbar.php
76 lines (67 loc) · 3.62 KB
/
navbar.php
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<nav class="navbar navbar-expand-lg bg-body-secondary">
<div class="container-fluid">
<a class="navbar-brand" href="index.php">Project Management Platform</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
<ul class="navbar-nav mb-2 mb-lg-0">
<?php
include 'db_connection.php';
$loggedIn = isset($_SESSION["UserID"]);
if ($loggedIn) {
$userID = $_SESSION["UserID"];
$query = "SELECT Username, PFPName FROM user WHERE UserID = ?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("i", $userID);
$stmt->execute();
$result = $stmt->get_result();
if (!$result) {
echo "Error: " . $mysqli->error;
exit();
}
$row = $result->fetch_assoc();
$mysqli->close();
echo '
<li class="nav-item">
<a class="nav-link" href="home.php">Dashboard</a>
</li>';
if (basename($_SERVER['PHP_SELF']) === 'home.php') {
echo '
<li class="nav-item">
<a class="nav-link" href="#" data-bs-toggle="modal" data-bs-target="#invitationsModal">Invitations</a>
</li>';
}
echo '
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" data-bs-display="static" aria-expanded="false">
'. $row["Username"] .'
<img class="rounded-circle" height="25" width="25" alt="Avatar" loading="lazy" style="object-fit: cover;" src="img/pfp/' . $row["PFPName"] . '" />
</a>
<ul class="dropdown-menu dropdown-menu-lg-end" style="min-width:inherit;">
<li><a class="dropdown-item" href="account.php">Details</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="logout.php">Logout</a></li>
</ul>
</li>
';
} else {
echo '
<li class="nav-item">
<a class="nav-link" href="index.php">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" data-bs-display="static" aria-expanded="false">Account</a>
<ul class="dropdown-menu dropdown-menu-lg-end" style="min-width:inherit;">
<li><a class="dropdown-item" href="login.php">Login</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="register.php">Register</a></li>
</ul>
</li>
';
}
?>
</ul>
</div>
</div>
</nav>