title: $_SESSION login x logout button script don't run, one more, cause it was marked as duplicate
body: <p>I've been doing a webpage with register/login php script. Everything works fine except $_SESSION variable, which should change login button to logout button. Idk, where I could be wrong. Can anyone help me please? </p>
  
  <p><strong>my header.php</strong>
      There is also &lt; ?php session_start(); ?> on the beggining of both files, but i can't show that inside this editor.</p>
  
  <pre><code>&lt;body&gt;
  &lt;header&gt;
  &lt;nav&gt;
      &lt;div class="main-wrapper"&gt;
          &lt;ul&gt;
              &lt;li&gt;&lt;a href="index.php"&gt;Loginsystem&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
          &lt;div class="nav-login"&gt;
              &lt;?php
              if (isset($_SESSION['u_uid'])) {
                  echo '&lt;form action="includes/logout.inc.php" method="POST"&gt;
                  &lt;button type="submit" name="submit"&gt;Logout&lt;/button&gt;
              &lt;/form&gt;';
              } else {
                  echo '&lt;form action="includes/login.inc.php" method="POST"&gt;
                  &lt;input type="text" name="uid" placeholder="Username/email"&gt;
                  &lt;input type="password" name="pwd" placeholder="password"&gt;
                  &lt;button type="submit" name="submit"&gt;Login&lt;/button&gt;
              &lt;/form&gt;
              &lt;a href="signup.php"&gt;Sign up&lt;/a&gt;';
              }
              ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/nav&gt;
  &lt;/header&gt;
  </code></pre>
  
  <p><strong>Login script</strong>
      
  
  <pre><code>if (isset($_POST['submit'])) {
  include 'dbh.inc.php';
  
  $uid = mysqli_real_escape_string($conn,$_POST['uid']);
  $pwd = mysqli_real_escape_string($conn,$_POST['pwd']);
  
  //Error handlers
  //Checks if inputs aren't empty
  if (empty($uid) || empty($pwd)) {
      header("Location: ../index.php?login=empty");
      exit();
  } else {
      $sql = "SELECT * FROM users WHERE user_uid = '$uid' OR user_email = 
  '$uid'";
      $result = mysqli_query($conn, $sql);
      $resultCheck = mysqli_num_rows($result);
      if ($resultCheck &lt; 1) {
          header("Location: ../index.php?login=error");
          exit();
      } else {
          if ($row = mysqli_fetch_assoc($result)) {
              //De-hashing pwd
              $hashedPwdCheck = password_verify($pwd, $row['user_pwd']);
              if ($hashedPwdCheck == false) {
                  header("Location: ../index.php?login=error");
                  exit();
              } elseif ($hashedPwdCheck == true) {
                  //Loging user
                  $_SESSION['u_id'] = $row[$user_id];
                  $_SESSION['u_name'] = $row[$user_name];
                  $_SESSION['u_email'] = $row[$user_email];
                  $_SESSION['u_uid'] = $row[$user_uid];
                  header("Location: ../index.php?login=success");
                  exit();
              }
          } 
      }
  }
  } else {
  header("Location: ../index.php?login=error");
  exit();
  </code></pre>