title: Set navbar selection to class active while also having the Login link switched to Logout if signed in?
body: <p>I'm trying to figure a way to have &quot;Login&quot; be set to logout, when a user is signed in, but also having their current navbar selection be highlighted in blue?</p>
  <p>I moved the html in the php below out of the html body. This html was repeated in every file for each page and <code>&lt;a class=&quot;active&quot; href=&quot;index.php&quot;&gt;Home&lt;/a&gt;</code> was different according to the page selection. I tried to minimize my code repetition by moving it to an external file to be called in via <code>&lt;?php include (&quot;scripts/navbar.php&quot;); ?&gt;</code>.</p>
  <p><a href="https://i.imgur.com/PE9rpEj.png" rel="nofollow noreferrer">For example</a> Here you can see Contact is blue because it's the page I'm currently on. But if a user is signed in, I want Contact to still be blue if they're currently on the Contact.php page, but to have Login changed to Log Out for the session. I have my logout script functioning correctly, but I'm not sure how to dynamically change both login to logout, while setting the selection to blue.</p>
  <pre><code>    &lt;?php if ( ! isset($_SESSION['username'] ) ): ?&gt;
          &lt;div class=&quot;topnav&quot;&gt;
        &lt;img src=&quot;assets/images/header5.jpg&quot;&gt;
            &lt;a href=&quot;Signin.php&quot;&gt;Login&lt;/a&gt;
        &lt;a href=&quot;contact.php&quot;&gt;Contact&lt;/a&gt;
        &lt;a href=&quot;about.php&quot;&gt;About&lt;/a&gt;
        &lt;a href=&quot;sample.php&quot;&gt;Sample&lt;/a&gt;
        &lt;a href=&quot;fees.php&quot;&gt;Fees&lt;/a&gt;
        &lt;a href=&quot;vintage.php&quot;&gt;Vintage&lt;/a&gt;
        &lt;a href=&quot;services.php&quot;&gt;Services&lt;/a&gt;
      &lt;a class=&quot;active&quot; href=&quot;index.php&quot;&gt;Home&lt;/a&gt;
      &lt;/div&gt;
          &lt;?php else: ?&gt;
      &lt;div class=&quot;topnav&quot;&gt;
        &lt;img src=&quot;assets/images/header5.jpg&quot;&gt;
            &lt;a href=&quot;/script/LogOut.php&quot;&gt;Logout&lt;/a&gt;
        &lt;a href=&quot;contact.php&quot;&gt;Contact&lt;/a&gt;
        &lt;a href=&quot;about.php&quot;&gt;About&lt;/a&gt;
        &lt;a href=&quot;sample.php&quot;&gt;Sample&lt;/a&gt;
        &lt;a href=&quot;fees.php&quot;&gt;Fees&lt;/a&gt;
        &lt;a href=&quot;vintage.php&quot;&gt;Vintage&lt;/a&gt;
        &lt;a href=&quot;services.php&quot;&gt;Services&lt;/a&gt;
     &lt;a class=&quot;active&quot; href=&quot;index.php&quot;&gt;Home&lt;/a&gt;
      &lt;/div&gt;
      &lt;?php endif; ?&gt;
  </code></pre>
  <p>I ideally didn't want to have 6-7 different files for the navbar,</p>