title: Php Session header already send error
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3319207/php-headers-already-sent-error">php headers already sent error</a>  </p>
  </blockquote>
  
  
  
  <p>I have attached my code which am using for a very basic login in php. It giving an error</p>
  
  <blockquote>
    <p>Cannot send session cookie - headers
    already sent by (output started at
    C:\xampp\htdocs\netsentries\f\includes\functions.php:1)</p>
  </blockquote>
  
  <pre><code>   &lt;?php 
      if (!isset($_POST['username'])) {
      ?&gt;
      &lt;h3&gt;Login&lt;/h3&gt;
      &lt;form action="" method="post"&gt;
      Username&lt;br/&gt;
      &lt;input name="username" type="text" /&gt;&lt;br/&gt;
      Password&lt;br/&gt;
      &lt;input name="password" type="password" /&gt;&lt;br/&gt;
      &lt;input name="" type="submit" /&gt;&lt;br/&gt;
      &lt;/form&gt;
      &lt;?php
      }
       else 
      { 
      include('includes/config.php');
  
      $data['username']= $_POST['username'];
      $data['password']= md5($_POST['password']);
  
      connect($db_name,$db_user,$db_pass,$db_host);
  
      $query= "select * from user where username='" . $data['username'] . "' AND password='" . $data['password'] . "'";
  
          $result=mysql_query($query);
          //check that at least one row was returned
          $rowCheck = mysql_num_rows($result);
          if($rowCheck &gt; 0)
          {
          while($row = mysql_fetch_array($result))
              {
              session_start();
              session_register($data['username']);
              //successful login code will go here...
              //echo 'Logged in!'; 
              }
          }
          else
          {
          echo "Failed!";
          }
  
  
  
      }
      ?&gt;
  </code></pre>
  
  <p>Am not able to find out the problem</p>