title: Changing Footer to label Login as Logout when the user is logged into the website
body: <p>I need some help getting the login in my footer to change to logout if the user is logged in. I  got it working on the login.php page, when the user logs in, it will label Log out, but if I go to About page, then it still says login. In my footer I have </p>
  
  <pre><code>&lt;?php
                  if(isset($_SESSION['user'])) {
                      print("&lt;a href=\"logout.php\"&gt;Log Out&lt;/a&gt;");
                  }
                  else{
                   print("&lt;a href=\"login.php\"&gt;Login&lt;/a&gt;");
                  }
              ?&gt;
  </code></pre>
  
  <p>but it does not seem to work, only on the login page. I will post the code for the about,login, and footer pages below. I must be doing something amiss with sessions since its only working on the one page,  but I cannot seem to find where. Sorry its a lot of code, but I wanted to paste it all just in case i didnt paste the part where the problem was occurring</p>
  
  <p>Thank you so much</p>
  
  <p>login.php</p>
  
  <pre><code>&lt;?php
  include "db.php";
  
  if (isset($_POST['username']) &amp;&amp; isset($_POST['password']))
  {
      $loginQuery = mysqli_query($con, "SELECT * FROM `users` WHERE `hashpassword` = '".sha1($_POST['password'])."' AND `username` = '".$_POST['username']."'");
      if (mysqli_num_rows($loginQuery) == 1) $_SESSION['user'] = $_POST['username'];
  
  }
  ?&gt;
  
  &lt;?php
      $pageName = "Administrator Login";
      include 'header.php';
  ?&gt;
  
  
  &lt;div class="one"&gt;
  &lt;?php
              if(isset($_SESSION['user'])) {
                  echo "Welcome! You are logged in as : ".$_SESSION['user'];
                  //adding photos
                  print("&lt;br/&gt;Add A Photo");
  
      $mysqli = new mysqli(DB_HOST,DB_USER,  DB_PASSWORD, DB_NAME);
  
                  $result = $mysqli-&gt;query("SELECT DISTINCT photoYear FROM Photos");
                  print('&lt;form method="post" enctype="multipart/form-data"&gt;&lt;table&gt;
  &lt;tr&gt;&lt;td&gt;*Upload Image&lt;/td&gt;&lt;td&gt;&lt;input type="file" name="newphoto"/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;*Year To Upload To&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="year"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td class="left"&gt;&lt;input type="submit" name="sub" value="Add Photo" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/form&gt;');
              }
  
      else {
      ?&gt;&lt;h1&gt;Please Login Here To Make Administrative Changes&lt;/h1&gt;
              &lt;form action="" method="post"&gt;
                  Username: &lt;input type="text" name="username"&gt; &lt;br&gt;
                  Password: &lt;input type="password" name="password"&gt; &lt;br&gt;
                  &lt;input type="submit" value="Log In"&gt;
              &lt;/form&gt;
  
              &lt;?php } ?&gt;
  
  
  
              &lt;?php
  
              /* creating new year albums and uploading photos
  
              if(isset($_SESSION['user'])){
                  //once user is logged in... can upload photos to certain years
  
  
      /* Adding photo to year albums
  print('&lt;form method="post" enctype="multipart/form-data"&gt;&lt;table&gt;
  &lt;tr&gt;&lt;td&gt;*Upload Image&lt;/td&gt;&lt;td class="left" &gt;&lt;input type="file" name="newphoto"/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;*Year To Upload To&lt;/td&gt;&lt;td class="left" &gt;&lt;select name="yearz"&gt;');
  while($row = $result -&gt; fetch_assoc()){
      $year=$row[ 'photoYear'];
      print("&lt;option value=".$year."&gt;".$year."&lt;/option&gt;");
  }
  print('&lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td class="left"&gt;&lt;input type="submit" name="sub" value="Add Photo" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/form&gt;');
  
  if (!empty($_FILES[ 'newphoto' ]) &amp;&amp; isset($_POST['yearz']) &amp;&amp; isset($_POST['sub'])){
  
                  $newPhoto = $_FILES[ 'newphoto' ];
                  $year = $_POST['yearz'];
  
                  $errors= array();
                  $maxsize = 2097152;
                  $acceptable = array(
                      'application/pdf',
                      'image/jpeg',
                      'image/jpg',
                      'image/gif',
                      'image/png'
                  );
  
                  if(($_FILES['newphoto']['size'] &gt;= $maxsize) || ($_FILES["newphoto"]["size"] == 0)) {
                      $errors[] = 'File too large. File must be less than 2 megabytes.';
                  }
  
                  if(!in_array($_FILES['newphoto']['type'], $acceptable)  &amp;&amp;  (!empty($_FILES['newphoto']['type']))) {
                      $errors[] = 'Invalid file type. Only PDF, JPG, GIF and PNG types are accepted.';
                  }
  
                  //next
              if(count($errors) ===0){
                  $originalName = str_replace(" ","_",$newPhoto[ 'name' ]);
                  $result = $mysqli-&gt;query("SELECT photoURL FROM Photos WHERE photoURL =".$originalName);
                          if (!($row = $result -&gt; fetch_assoc())){
                              $test = explode('|', $_POST['alb']);
                              $albumid = $test[0];
                              $caption = $_POST[ 'caption' ];
  
                              if ($newPhoto['error'] == 0){
  
                                  $tempName = $newPhoto[ 'tmp_name' ];
                                  move_uploaded_file( $tempName, "$originalName");
                                  $_SESSION[ 'photos'][] = $originalName;
                                  print("File was uploaded.");
  
                                  $adding = "INSERT INTO Photos (`photoURL`,`photoYear`) 
                                  VALUES('$originalName', '$yearz');";
                                  $mysqli -&gt; query($adding);
  
                              }
                          }
                      else{
                           print("This photo is already in the database. Try uploading another.");    
                          }
  
                  }
  
          else{
                   foreach($errors as $error) {
                          echo '&lt;script&gt;alert("'.$error.'");&lt;/script&gt;';
                      }   
                      die();
                  }
  
          }
          //outer
  
      }
  
      */
  
              ?&gt;
              &lt;/div&gt;
  
  
  
  &lt;?php
      include "db.php";
      include 'footer.php';
      session_unset();
      session_destroy();
  ?&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>about.php</p>
  
  <pre><code>&lt;?php
      $pageName = "About RFYC";
      include 'header.php';
  ?&gt;
  
  &lt;div class="one"&gt;
      &lt;img class="center" src="images/logo/black.png" alt="logo"&gt;
      &lt;p&gt;
          Root For Your Cause is an annual charity root beer pong tournament held at Cornell University. The event is sponsored by Alpha Phi Omega - Gamma Chapter, a national community service fraternity. When registering for the event each team or organization selects a charity to play for. At the end of this single-elimination tournament, the entire sum of money earned through registration is then donated to the winning team's charity of choice!&lt;br/&gt;
      &lt;/p&gt;
      &lt;p&gt;
          The event is also friendly to spectators. There is music, plenty of chairs to watch friends compete, and we sell root beer floats throughout the competition.
          The registration fee is $10 per two-person team for individual teams, and $8 per two-person team for organizations registering 5 or more teams who will all be competing for the same charity.
          For more information, contact &lt;span id="email"&gt;philanthropy@apogamma.org&lt;/span&gt;
      &lt;/p&gt;
  &lt;/div&gt;
  
  &lt;div class="winners"&gt;
      &lt;h1&gt;Past Winners&lt;/h1&gt;
  
  &lt;figure&gt;
  &lt;figcaption&gt;2011&lt;br/&gt;
  &lt;img src="images/icons/placeholder_circle.png" alt="winner"&gt;&lt;br/&gt;
  Team Name&lt;br/&gt;Charity&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;figure&gt;
  &lt;figcaption&gt;2012&lt;br/&gt;
  &lt;img src="images/icons/placeholder_circle.png" alt="winner"&gt;
  &lt;br/&gt;Team Name&lt;br/&gt;Charity&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;figure&gt;
  &lt;figcaption&gt;2013&lt;br/&gt;
  &lt;img src="images/icons/placeholder_circle.png" alt="winner"&gt;
  &lt;br/&gt;Team Name&lt;br/&gt;Charity&lt;/figcaption&gt;
  &lt;/figure&gt;
  
  &lt;/div&gt;
  
  
  &lt;?php
      include 'footer.php';
  ?&gt;
  
  
  
  &lt;/html&gt;
  </code></pre>
  
  <p>footer.php</p>
  
  <pre><code>&lt;div id="wrapper"&gt;
      &lt;div id="footer"&gt;
          &lt;div class="footerFloat"&gt;
              &lt;h4&gt;Site Map&lt;/h4&gt;
  
                  &lt;a href="about.php"&gt;About&lt;/a&gt; &lt;br/&gt;
                  &lt;a href="rules.php"&gt;Rules&lt;/a&gt;&lt;br/&gt;
                  &lt;a href="gallery.php"&gt;Gallery&lt;/a&gt;&lt;br/&gt;
                  &lt;a href="bracket.php"&gt;Bracket&lt;/a&gt;&lt;br/&gt;
                  &lt;a href="register.php"&gt;Register&lt;/a&gt;
  
          &lt;/div&gt;
          &lt;div class="footerFloat"&gt;
              &lt;h4&gt;Connect With Us&lt;/h4&gt;
              &lt;ul&gt;
                  &lt;li&gt;&lt;img src="images/icons/email.png" alt="email"&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;img src="images/icons/fb.png" alt="fb"&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;img src="images/icons/twitter.png" alt="twitter" &gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
          &lt;div class="footerFloat"&gt;
              &lt;h4&gt;Manage&lt;/h4&gt;
              &lt;?php
                  if(isset($_SESSION['user'])) {
                      print("&lt;a href=\"logout.php\"&gt;Log Out&lt;/a&gt;");
                  }
                  else{
                   print("&lt;a href=\"login.php\"&gt;Login&lt;/a&gt;");
                  }
              ?&gt;
          &lt;/div&gt;
          &lt;div class="footerFloat"&gt;
              &lt;h4&gt;Brought to You By&lt;/h4&gt;
              &lt;a href="http://apogamma.org/"&gt;Alpha Phi Omega - Cornell Chapter &lt;/a&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  
      &lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="js/interactivity.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>