I need help with displaying a navbar on my webpage. I want the right side of the navbar to show different elements based on whether the user is logged in or not. If the user is not logged in, it should display "Login" and "Register," and if they are logged in, it should display "Hi, >username<" and "Logout." Currently, my code only works for when the user is not logged in. After they log in, the right part shows: Hi, Logout
username<
Can someone please assist me with this?
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
</button>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="member.php?lang=en">English</a></li>
<li><a href="member.php?lang=zh">中文</a></li>
<li><a href="<?php echo lnkIndex; ?>"><img alt="KnowSG.com" src="images/knowsg_icon.png" style="height:20px"/></a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<?php
if(isset($_SESSION["valid_user"])) {
$msg = "<li>Hi, <a href=\"".lnkMember."\">".$_SESSION["valid_user"]."</a></li><li><a href=\"".lnkLogout."\">".strLogout."</a></li>";
echo $msg;
}
else {
echo "<li><a href=\"".lnkLogin."\">".strLogin."</a></li><li><a href=\"".lnkRegister."\">".strRegistr."</a></li>";
}
?>
</ul>
</div>
</div>
</nav>