title: Hide login/register button when logged in and hide logout button when logged out
body: <p>i'm kinda new in PHP and I have some issues. When I'm logged in on my website I want to hide the 'Login' and 'Register' button, and when I'm logged out I want to hide the 'logout' button.</p>
  
  <p>This is my login.php page:</p>
  
  <pre><code>&lt;?php
      include "navbar.php";
  ?&gt;
  &lt;?php
      include_once "check.php";
  
      $error = ""; //Variable for storing our errors.
      if(isset($_POST["submit"]))
      {
          if(empty($_POST["username"]) || empty($_POST["password"]))
          {
              $error = "Both fields are required.";
          }else
          {
              // Define $username and $password
              $username=$_POST['username'];
              $password=$_POST['password'];
  
              // To protect from MySQL injection
              $username = stripslashes($username);
              $password = stripslashes($password);
              $username = mysqli_real_escape_string($db, $username);
              $password = mysqli_real_escape_string($db, $password);
              $password = md5($password);
  
              //Check username and password from database
              $sql="SELECT uid FROM users WHERE username='$username' and password='$password'";
              $result=mysqli_query($db,$sql);
              $row=mysqli_fetch_array($result,MYSQLI_ASSOC);
  
              //If username and password exist in our database then create a session.
              //Otherwise echo error.
  
              if(mysqli_num_rows($result) == 1)
              {
                  $_SESSION['username'] = $username;
                  header("location: index.php");
              }else
              {
                  $error = "Incorrect username or password.";
              }
  
          }
      }
  
  ?&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;link rel="stylesheet" type="text/css" href="assets/css/acc.css"&gt;
          &lt;link rel="stylesheet" type="text/css" href="assets/css/acc2.css"&gt;
          &lt;link rel="stylesheet" type="text/css" href="assets/css/navbar.css"&gt;
          &lt;title&gt;Login | Peerbolte-ICT&lt;/title&gt;
      &lt;/head&gt;
      &lt;/body&gt;
          &lt;section&gt;
          &lt;p style="color:red;"&gt;&lt;?php echo $error; ?&gt; &lt;/p&gt;
              &lt;form method="POST" action=""&gt;
                  &lt;div class="accPanel"&gt;
                  &lt;h1 style="color: black; padding-bottom: 5%;"&gt;Login&lt;/h1&gt;
                  &lt;form method="POST" action=""&gt;
                      &lt;div class="login-input"&gt;
                          &lt;label class="accLabel"&gt;&lt;b&gt;Username&lt;span style="color:red;"&gt;*&lt;/span&gt;&lt;/b&gt;&lt;/label&gt;
                          &lt;input type="text" placeholder="Enter Username" name="username" required&gt;
  
                          &lt;label class="accLabel"&gt;&lt;b&gt;Password&lt;span style="color:red;"&gt;*&lt;/span&gt;&lt;/b&gt;&lt;/label&gt;
                          &lt;input type="password" placeholder="Enter Password" name="password" required&gt;
  
                          &lt;button class="submitButton" type="submit" name="submit"&gt;Login&lt;/button&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/section&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And this is my navbar.php where the buttons are:</p>
  
  <pre><code>&lt;ul&gt;
    &lt;li&gt;&lt;a href="index.php"&gt;Home&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#bannerTwo"&gt;Services&lt;/a&gt;&lt;/li&gt;
    &lt;li class="dropdown"&gt;
      &lt;a href="javascript:void(0)" class="dropbtn"&gt;Our Work&lt;/a&gt;
      &lt;div class="dropdown-content"&gt;
        &lt;a href="#"&gt;Link 1&lt;/a&gt;
        &lt;a href="#"&gt;Link 2&lt;/a&gt;
        &lt;a href="#"&gt;Link 3&lt;/a&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class="dropdown"&gt;
      &lt;a href="javascript:void(0)" class="dropbtn"&gt;Account&lt;/a&gt;
      &lt;div class="dropdown-content"&gt;
        &lt;a href="login.php"&gt;Login&lt;/a&gt;
        &lt;a href="register.php"&gt;Register&lt;/a&gt;
        &lt;a href="logout.php"&gt;Logout&lt;/a&gt;
      &lt;/div&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Thanks</p>