title: Cant get variable from MySQL using PHP
body: <p>I need to get some data from MySQL DB (it certainly exists) to proceed and analyse it. So, what I have in my code:</p>
  
  <pre><code>  if (count($errors) == 0)  
  $password = md5($password); 
  $query = "SELECT username, password, email FROM trackowners WHERE username='$username' AND password='$password'"; 
  $results = mysqli_query($db, $query); 
  if (mysqli_num_rows($results) == 1) {
    ///////////
    $_SESSION['username'] = $username;
    $_SESSION['success'] = "You are now logged in";
    $_SESSION['email'] = $email;
    header('location: index.php');
  }else {
    array_push($errors, "Wrong username/password combination");
  } }
  </code></pre>
  
  <p>Then I am trying to use variables $_SESSION['username'] and email one:</p>
  
  <pre><code>&lt;?php  if (isset($_SESSION['username'])) : ?&gt;
      &lt;p&gt;Welcome &lt;strong&gt;&lt;?php echo $_SESSION['username']; ?&gt;&lt;/strong&gt; // Here are your profile settings.&lt;/p&gt;
  
      &lt;p&gt; &lt;a href="index.php?logout='1'" style="color: red;"&gt;logout&lt;/a&gt; &lt;/p&gt;
  &lt;?php endif ?&gt;
  
    &lt;?php  if (isset($_SESSION['username'])) : ?&gt;
    &lt;p&gt;Your e-mail&lt;strong&gt;&lt;?php echo $_SESSION['email']; ?&gt;&lt;/strong&gt; //&lt;/p&gt;
  &lt;?php endif ?&gt;
  </code></pre>
  
  <p>And here I am getting username variable but I cant get anything from email variable. Whats the problem?</p>
  
  <p>Thanks in advance!</p>