title: if statements and sessions
body: <p>I am attempting change the menu accordingly if the user is logged in or not. It keeps on coming up with this error:</p>
  
  <p>Notice: Undefined variable: _SESSION in C:\xampp2\htdocs\JobBoard\menu.php on line 3
  menu.php</p>
  
  <pre><code>&lt;?php
  
  $useremail = $_SESSION['login_user'];
  
  if($useremail==NULL)
  {
   $loggedinout='&lt;div id="menulogin"&gt;&lt;a href="register.php"&gt;Register&lt;/a&gt; | &lt;a href="login.php"&gt;Login&lt;/a&gt; &amp;nbsp &lt;/div&gt;';
   }
   else
   $loggedinout='&lt;div id="menulogin"&gt;&lt;a href="logout.php"&gt;Logout&lt;/a&gt; &amp;nbsp &lt;/div&gt;';
  
  echo'
  &lt;link rel="stylesheet" type="text/css" href="stylesheets/menu.css" /&gt;
  &lt;div id="menucontainer"&gt;' . $loggedinout . '&lt;div id="menulogo"&gt;&lt;img src="images/logo.png" /&gt;&lt;/div&gt;
  &lt;div id="searchmenu"&gt;&lt;/div&gt;
  '
  ?&gt;
  </code></pre>
  
  <p>This is my page whwere I start the session
  login.php</p>
  
  <pre><code>&lt;?php
  include 'menu.php';
  include 'db_connect.php';
  session_start();
  if($_SERVER["REQUEST_METHOD"] == "POST")
  {
  // email and password sent from Form 
  $myemail=addslashes($_POST['email']); 
  $mypassword=addslashes($_POST['password']); 
  
  $sql="SELECT userID FROM users WHERE email='$myemail' and password='$mypassword'";
  $result=mysql_query($sql);
  $row=mysql_fetch_array($result);
  $active=$row['active'];
  $count=mysql_num_rows($result);
  
  
  // If result matched $myemail and $mypassword, table row must be 1 row
  if($count==1)
  {
  session_register("myemail");
  $_SESSION['login_user']=$myemail;
  
  header("location: index2.php");
  }
  else 
  {
  $error="location: test.php";
  }
  }
  ?&gt;
  </code></pre>
  
  <p>I'm sure it's quite an easy thing for someone. Please help</p>