title: Error Changing Page Content Using Session Values
body: <p>My goal is to change the content in header file using session variables.
  The scenario is:</p>
  
  <ol>
  <li>In index.php,next to the Login button(this button is located at header.php) there is a text "Login first".</li>
  <li>Login</li>
  <li>Redirect to index.php but in header the text next to login button will be changed to "User is: " . $_SESSION['u_id'] . "now"". (e.g User is Paul now)</li>
  </ol>
  
  <p>Any ideas?The login is working but the content is not changed.Thanks in advance!</p>
  
  <p>[UPDATE]: Problem is solved! I forgot to declare variable $row ($row = mysqli_fetch_assoc($result); )</p>
  
  <p>index.php file:</p>
  
  <pre><code>&lt;?php
    include_once 'header.php';
  ?&gt;
  
  .
  .
  .
  </code></pre>
  
  <p>header.php file:</p>
  
  <pre><code>&lt;?php
    session_start();
  ?&gt;  
  
  .
  .
  . 
  
  &lt;?php
  if (isset($_SESSION['u_id']))
  {
     echo  "User is: " . $_SESSION['u_first'] . "now" ;
  }
  else
  {
     echo "Login first";
  }
  ?&gt;
  </code></pre>
  
  <p>login.php file:</p>
  
  <pre><code>&lt;?php
  
  session_start();
  
  if (isset($_POST['submit']))
  {
  include 'dbh.inc.php';
  
  $uid = mysqli_real_escape_string($conn,$_POST['uid']);
  $pwd = mysqli_real_escape_string($conn,$_POST['pwd']);
  
  $sql = "SELECT * FROM users WHERE user_uid = '$uid' AND user_pwd = '$pwd' ";
  $result = mysqli_query($conn,$sql);
  $resultCheck = mysqli_num_rows($result);
  
  if($resultCheck &lt; 1)
  {
      header("Location: ../index.php?login=error");
      exit();
  }
  else
  {
      //LOGIN
      $_SESSION['u_id'] = $row['user_id'];
      $_SESSION['u_first'] = $row['user_first'];
      $_SESSION['u_last'] = $row['user_last'];
      $_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>