title: Deprecated: Function session_register() is deprecated and Cannot modify header information
body: <p>I created a simple login system using sql</p>
  
  <p>It has 4 main components
  index -asks for username and pass
  checklogin - checks for the credentials
  logsuccess
  homepage - landing page after successful login</p>
  
  <p>The error generate are given at the end of the post</p>
  
  <pre><code>Index.php asks for username and pass
  
      &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
      &lt;HTML&gt;
       &lt;HEAD&gt;
        &lt;TITLE&gt;Nottingham Uni&lt;/TITLE&gt;
  
        &lt;script type="text/javascript" src="js/mootools-1.2.1-core-yc.js"&gt;&lt;/script&gt;
        &lt;script type="text/javascript" src="js/process.js"&gt;&lt;/script&gt;
  
        &lt;link rel="stylesheet" type="text/css" href="style.css" /&gt;
      &lt;/HEAD&gt;
  
       &lt;BODY&gt;
  
      &lt;center&gt;
      &lt;div id="intro"&gt;
        &lt;p&gt;&amp;nbsp;&lt;/p&gt;
        &lt;p&gt;&lt;img align="absmiddle" src="images/nott-uni-logo.jpg"&gt;&lt;/p&gt;
      &lt;/div&gt;
  
      &lt;div id="status"&gt;
  
      &lt;fieldset&gt;&lt;legend align="center"&gt;Authentication&lt;/legend&gt;
  
      &lt;div id="login_response"&gt;&lt;!-- spanner --&gt;&lt;/div&gt;
  
      &lt;form id="login" name="login" method="post" action="checklogin.php"&gt;
      &lt;table align="center" width="300" border="0"&gt;
      &lt;tr&gt;
      &lt;td width="80"&gt;Username&lt;/td&gt;&lt;td&gt;&lt;input id="name" type="text" name="myusername"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;Password&lt;/td&gt;
      &lt;td&gt;&lt;input type="password" name="mypassword"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&lt;input id="submit" type="submit" name="submit" value="Login"&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/form&gt;
      &lt;/fieldset&gt;
  
      &lt;/div&gt;
      &lt;/center&gt;
       &lt;/BODY&gt;
      &lt;/HTML&gt;
  
  
  checklogin.php checks for the credentials
  
      &lt;?php
  
      $link = mysql_connect('www.xxxxx.com', 'xxxxxx', 'xxxxxx');
      if (!$link) {
          die('Could not connect: ' . mysql_error());
      }
  
      mysql_select_db("brainoidultrafb", $link);
  
      // username and password sent from form 
      $myusername=$_POST['myusername']; 
      $mypassword=$_POST['mypassword']; 
  
      // To protect MySQL injection (more detail about MySQL injection)
      $myusername = stripslashes($myusername);
      $mypassword = stripslashes($mypassword);
      $myusername = mysql_real_escape_string($myusername);
      $mypassword = mysql_real_escape_string($mypassword);
      $sql="SELECT * FROM logintbl WHERE stu_email='$myusername' and password='$mypassword'";
      $result=mysql_query($sql);
  
      // Mysql_num_row is counting table row
      $count=mysql_num_rows($result);
  
      // If result matched $myusername and $mypassword, table row must be 1 row
      if($count==1){
  
      // Register $myusername, $mypassword and redirect to file "login_success.php"
      session_register("myusername");
      session_register("mypassword"); 
      header("location:login_success.php");
      }
      else {
      echo "Wrong Username or Password";
      }
      ?&gt;
  
  
  If its success it goes to homepage.php
  
  logsuccess.php is below
  
      &lt;?php
      session_start();
      if(!session_is_registered(myusername)){
      header("location:homepage.php");
      }
      ?&gt;
      &lt;html&gt;
      &lt;body&gt;
      Login Successful
      &lt;/body&gt;
      &lt;/html&gt;
  
  
  these codes are give in the following errors
  
      Deprecated: Function session_register() is deprecated in /home/content/58/9508458/html/pabrowser/checklogin.php on line 29
  
      Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/content/58/9508458/html/pabrowser/checklogin.php:29) in /home/content/58/9508458/html/pabrowser/checklogin.php on line 29
  
      Deprecated: Function session_register() is deprecated in /home/content/58/9508458/html/pabrowser/checklogin.php on line 30
  
      Warning: Cannot modify header information - headers already sent by (output started at /home/content/58/9508458/html/pabrowser/checklogin.php:29) in /home/content/58/9508458/html/pabrowser/checklogin.php on line 31
  </code></pre>