title: Inline login form php in every single page
body: <p><img src="https://i.stack.imgur.com/XSTqF.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/MH8rn.png" alt="enter image description here"></p>
  
  <p>So I'm trying to do a login section in every single page of my web app 
  it looks like the attached pictures, but I'm having a hard time with the sessions. </p>
  
  <p>if the user is logged in DON'T DISPLAY THE FORM > display dropdown list 
  but I always get the drop down without the registration, </p>
  
  <p>I want a simple code that would do that for me coz I'm confused 
  is there a simple way to guide me through the process? Thanks </p>
  
  <pre><code>        &lt;?php
  
                  /*
                   *Create db in mydb for users
                   *connect
                   *recieve from login forum &gt;&gt; check with db if exists
                   *start session &gt; save the id of that user &gt;&gt; display the forum with details of his profile
                   */
  
                  /*
                  if(isset($_POST["submit"])){
                      $user= $_POST["username"];
                      $pass= $_POST["password"];
                      //$_SESSION["username"]=$user;
                      echo "username is clicked";
                  }else{
                      echo "nothing is clicked";
                  }
                  */
  
                  $signin=false; // checking the concept
                  $_SESSION["username"] =$signin;
                  if(isset($_SESSION["username"])){ #if the user is signed in 
  
                    echo $_SESSION["username"];
                      $query= "select * from users";
                      $select= mysqli_query($connection, $query);
                      while ($row = mysqli_fetch_assoc($select)){
                          $userid = $row["idusers"];
                          $username=$row["username"];
                          $password= $row["password"];
  
                      }
                  ?&gt;
                    &lt;ul class="nav navbar-nav navbar-right"&gt;
                      &lt;li&gt;
                          &lt;a href="help.html"&gt;Help&lt;/a&gt;
                      &lt;/li&gt;
                      &lt;li class="dropdown"&gt;
                           &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown"&gt;&lt;?php echo $username;?&gt;&lt;strong class="caret"&gt;&lt;/strong&gt;&lt;/a&gt;
                          &lt;ul class="dropdown-menu"&gt;
                              &lt;li&gt;
                                  &lt;a href="profile.php?id=&lt;?php echo "$userid";?&gt;"&gt;Profile&lt;/a&gt;
                              &lt;/li&gt;
                              &lt;li&gt;
                                  &lt;a href="#"&gt;Contests&lt;/a&gt;
                              &lt;/li&gt;
  
                              &lt;li class="divider"&gt;
                              &lt;/li&gt;
                              &lt;li&gt;
                                  &lt;a href="signout.php"&gt;SignOut&lt;/a&gt;
                              &lt;/li&gt;
                          &lt;/ul&gt;
                      &lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/div&gt;&lt;?php
                  }else{
  
                      ?&gt;
                        &lt;form class="navbar-form navbar-right" method="post" role="search"&gt;
                        &lt;div class="form-group"&gt;
                            &lt;input type="text" class="form-control" name="username" placeholder="Username"&gt;
                        &lt;/div&gt;
                        &lt;div class="form-group"&gt;
                            &lt;input type="password" class="form-control" name="password" placeholder="Password"&gt;
                        &lt;/div&gt;
                        &lt;button type="submit" class="btn btn-default"&gt;Sign In&lt;/button&gt;
                        &lt;/form&gt;
  
  
                      &lt;?php 
  
                  }
  
                  ?&gt;
  </code></pre>