title: Show a message if user is not logged in
body: <p>My home page has an link to the profile page (profile.php). The profile page can only be seen by the users who are logged in. If a user clicks the profile link before log in he/she will be redirected to the login page (login.php) and a message (<code>$mssg</code>) will appear on the top of the log in form. <strong>--- this is what I want.</strong></p>
  
  <p><strong>What is wrong in my observation:</strong>  The header function can't seem to get the <code>$mssg</code> along with the page location.</p>
  
  <p><strong>profile.php:</strong></p>
  
  <pre><code>&lt;?php
  session_start();
  if(empty($_SESSION['valid'])){
  $_SESSION['intruder']="stranger";
  header('Location: login.php?$mssg=" You are not logged in. Please log in to see the profile. "');
  }
  ?&gt; 
  </code></pre>
  
  <p><strong>login.php</strong> </p>
  
  <pre><code>&lt;?php
  session_start();
  if (empty($_SESSION['intruder'])) //print nothing
  else {
    echo $mssg;
  }
  // log in form code, email, password etc.
  ?&gt;
  </code></pre>
  
  <p><strong>The error I'm geting:</strong></p>
  
  <blockquote>
    <p>Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\sss\login.php on line 4</p>
  </blockquote>
  
  <p>Why is it not working? Do you think my code is wrong? If so, then how can I fix it or get what I want?</p>