Possible Duplicate:
Warning: Cannot modify header information - headers already sent
Headers already sent by PHP
Error: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\GameHutWebsite\data\connection.php:1) in C:\xampp\htdocs\GameHutWebsite\login.php on line 21
I am getting this error when the user enters the correct username and password in the login screen to send the user in the home page. This is the code:
<?php
if ($_POST)
    {
        $dsLogin = $dataobj->validateLogin($_POST["txtUsername"],$_POST["txtPassword"]);
        if (mysql_num_rows($dsLogin))
        {
            $dsUserDetails = mysql_fetch_array($dsLogin);
            $_SESSION["UserEmail"] =  $dsUserDetails["UserEmail"];
            $_SESSION["Username"] =  $dsUserDetails["Username"];
            $_SESSION["UserTypeId"] =  $dsUserDetails["UserTypeId"];
            header ("Location: index.php");
        }
        else
        {
            $msg = "Invalid Username and Password!";
        }
    }
?>
Connection Class:
<?php
class connection
{   
    function connect($sql)
    {
        $server = 'localhost';
        $myDB = 'gamehutdb'; 
        //connection to the database
        $dbhandle = mysql_connect($server, 'root', "")
            or die("Couldn't connect to SQL Server $server"); 
        //select a database to work with
        $selected = mysql_select_db($myDB)
            or die("Couldn't open database $myDB"); 
        //execute the SQL query and return records
        $result = mysql_query($sql);
        //return result set
        return $result;
        //close the connection
        mysql_close($dbhandle); 
    }
}
?>
 
     
     
     
    