title: user not displaying via session variable
body: <p>i am new to the PHP and i building a website which is mostly copied from diff sources and i want the user who had logged in to be displayed but it does not. here is my HTML for the page </p>
  
  <pre><code>&lt;?PHP
  
  session_start();
  
  if (!(isset($_SESSION['username']) &amp;&amp; $_SESSION['username'] != '')) {
  
  header ("Location: checklogin.php");
  
  }
  
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
   &lt;head&gt;
  
  &lt;title&gt;MAP MY WAY&lt;/title&gt;
  &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no" /&gt;
  
  &lt;meta name="description" content="Google Maps API V3: Custom Directions Panel" /&gt;
  &lt;meta name="keywords" content="final_project" /&gt;
  &lt;meta name="author" content="Zohaib Tasnim" /&gt;
  
   &lt;script type="text/javascript"   
   src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;
   &lt;script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?      
   v=3.exp&amp;sensor=true&amp;libraries=places"&gt;&lt;/script&gt;
  &lt;link href="style.css" type="text/css" rel="stylesheet" /&gt;
  
  
  &lt;!--to disable the enter key--&gt;
  &lt;script type="text/javascript"&gt; 
  
   function stopRKey(evt) { 
   var evt = (evt) ? evt : ((event) ? event : null); 
   var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
   if ((evt.keyCode == 13) &amp;&amp; (node.type=="text"))  {return false;} 
   } 
  
   document.onkeypress = stopRKey; 
  
   &lt;/script&gt;
  
  
   &lt;/head&gt;
   &lt;body&gt;
   &lt;div id="mapCanvas"&gt;&amp;#160;&lt;/div&gt;
   &lt;div id="box"&gt;
      &lt;a id="btns"&gt; welcome &lt;?php echo($_SESSION['username']); ?&gt;&lt;/a&gt;
      &lt;a id="btns" href="profile.html"&gt; My Profile&lt;/a&gt;
      &lt;a id="btns" href="login.php"&gt; logout&lt;/a&gt;
      &lt;p class="or"&gt;[OR]&lt;/p&gt;
      &lt;div class="directionInputs"&gt;
          &lt;form action="address_insert.php" name="form2" method="post"&gt;
              &lt;p&gt;&lt;label&gt;A&lt;/label&gt;&lt;input type="text" value=""  name="loc_a" 
    id="dirSource" /&gt;&lt;/p&gt;
              &lt;p&gt;&lt;label&gt;B&lt;/label&gt;&lt;input type="text" value="" name="loc_b" 
    id="dirDestination" /&gt;&lt;/p&gt;
              &lt;a href="#getDirections" id="getDirections"&gt;Get Directions&lt;/a&gt;
              &lt;a href="#reset" id="paneReset"&gt;Reset&lt;/a&gt;
              &lt;a id="btns"&gt;&lt;input name="submit" class="btns" type="submit" value="Save       
    Address" /&gt;&lt;/a&gt;
          &lt;/form&gt; 
      &lt;/div&gt;
  
      &lt;div id="directionSteps"&gt;
          &lt;p class="msg"&gt;Direction Steps Will Render Here&lt;/p&gt;
      &lt;/div&gt;
      &lt;!--&lt;a href="#toggleBtn" id="paneToggle" class="out"&gt;&amp;lt;&lt;/a&gt;--&gt;
  &lt;/div&gt;
  &lt;script type="text/javascript" src="sample.js"&gt;&lt;/script&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and checklogin.php is</p>
  
  <pre><code>&lt;?php
  
   $host="localhost"; // Host name 
  $username="root"; // Mysql username 
  $password=""; // Mysql password 
  $db_name="map_my_way"; // Database name 
  $tbl_name="members"; // Table name 
  
  // Connect to server and select databse.
  mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
  mysql_select_db("$db_name")or die("cannot select DB");
  
  // username and password sent from form 
  $username=$_POST['username']; 
  $password=$_POST['password']; 
  
  // To protect MySQL injection (more detail about MySQL injection)
  $username = stripslashes($username);
  $password = stripslashes($password);
  $username = mysql_real_escape_string($username);
  $password = mysql_real_escape_string($password);
  $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
  $result=mysql_query($sql);
  
  // Mysql_num_row is counting table row
  $count=mysql_num_rows($result);
  
  // If result matched $username and $password, table row must be 1 row
  if($count==1){
  
  // Register $username
  session_start();
  $_SESSION['login'] = true;
  $_SESSION['username'] = $username;
  header("location:user_index.html");
  
  }
  else {
  
  echo "Wrong Username or Password";
  }
  ?&gt;
  </code></pre>