title: Undefined index: username when using sessions
body: <p>I'm working on a forum software right now, and I'm doing very well so far, it all works, but I can't get this to get away, I'm not really sure how.</p>
  
  <p>I get Undefined index: username whenever I call</p>
  
  <pre><code>$_SESSION['username']
  </code></pre>
  
  <p>I start the session in a seperate login file, but get this error whenever calling it, I only get it when someone isn't logged in, so like if I'm logged in, it doesn't show it, only when I'm not logged in, how can I get rid of it?</p>
  
  <p>Here's my whole code for the page:</p>
  
  <pre><code>&lt;?php
  session_start();
  include_once("connect.php");
  
  $find = "SELECT id,name,description FROM forums";  
  $run_find = mysql_query("$find");
  if ($_SESSION['username']) {
  print "Welcome, " . $_SESSION['username']. "!&lt;br/&gt;";
  }
  while($is = mysql_fetch_assoc ($run_find)) 
  {
  $id = $is['id'];
  $name = $is['name'];
  $des = $is['description'];
  
  print "&lt;div style='width:500px;background-color:#FFCCFF;'&gt;";
  print "Forum : &lt;a href='topics.php?t=$id'&gt;". $name . "&lt;/a&gt;&lt;br/&gt;" .$des . "&lt;br/&gt;&lt;hr&gt;";
  print "&lt;/div&gt;";
  }
  
  if (!$_SESSION['username']) {
  echo "
  &lt;form action='loginnext.php' method='post'&gt;
  Username: &lt;input type='text' name='username'&gt;&lt;br/&gt;
  Password: &lt;input type='password' name='password'&gt;&lt;br/&gt;
  &lt;input type='submit' name='submit' value='Login'&gt;&lt;br/&gt;&lt;/form&gt;";
  }
  if ($_SESSION['username']) {
  echo "&lt;a href='logout.php'&gt;Logout&lt;/a&gt;";
  }
  ?&gt;
  </code></pre>