PHP error wont go away. Please Help
<p>I am getting the following error “Warning: Cannot modify header information - headers already sent by”, and the answers in <a href="http://stackoverflow.com/questions/1912029/warning-cannot-modify-header-information-headers-already-sent-by-error">this question</a> are not solving this problem.</p>

<p>Could anybody please help me?</p>

<p>This is my code.</p>

<p><strong>main_login</strong></p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
    &lt;title&gt;Untitled Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form name="form1" method="post" action="checklogin.php"&gt;
    &lt;table style="width:300px;border:0;text-align:center;background-color:#CCCCCC"&gt;
        &lt;tr&gt;
            &lt;td&gt;
                &lt;table style="width:100%;background-color:#FFFFFF;border:0;"&gt;
                    &lt;tr&gt;
                        &lt;td colspan="3"&gt;&lt;strong&gt;Member Login &lt;/strong&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td style="width:78px"&gt;Username&lt;/td&gt;
                        &lt;td style="width:6px"&gt;:&lt;/td&gt;
                        &lt;td style="width:294px"&gt;&lt;input name="myusername" type="text" id="myusername"&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td&gt;Password&lt;/td&gt;
                        &lt;td&gt;:&lt;/td&gt;
                        &lt;td&gt;&lt;input name="mypassword" type="text" id="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;td&gt;&lt;input type="submit" name="Submit" value="Login"&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/table&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p><strong>checkLogin.php</strong></p>

<pre><code>&lt;?php
$dbhost = 'localhost';
$dbuser = 'myuse';
$dbpass = 'myPassword';
$dbname = 'myDbName';

// This is an example opendb.php
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die  ('Error connecting to mysql');
mysql_select_db($dbname);


// 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 myTable WHERE username='$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['myusername'] = $myusername;
$_SESSION['mypassword']   = $mypassword;
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?&gt;
</code></pre>

<p><strong>login_success.php</strong></p>

<pre><code>&lt;?php
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
// Check if session is not registered , redirect back to main page. // Put this
code in first line of web page.
&lt;html&gt;
&lt;body&gt;
    Login Successful
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>This is the <strong>error</strong></p>

<p>Warning: Cannot modify header information - headers already sent by (output started at /home/latabla1/public_html/MenuSemanal/checklogin.php:1) in /home/latabla1/public_html/MenuSemanal/checklogin.php on line 34.</p>

<p>The connection  to the database is fine as when I type wrong login details it goes to echo "Wrong Username or Password";, and I've checked the white spaces, but I cant find what is wrong.</p>

<p>Please help, I have been one whole day trying to fix this.</p>
