Headers are giving me headaches again. I'm getting the following error:
Warning: Cannot add header information - headers already sent by (output started at /home/virtual/site206/fst/var/www/html/index.php:23) in /home/virtual/site206/fst/var/www/html/modules/utilities/login.inc on line 110
Any suggestions? I've checked the includes for spaces and have removed any that popped up.
Here's the code for login.inc:
<?php
//includes
include_once 'includes/common.inc';
// Include the MySQL class
require_once 'classes/mySql.php';
require_once 'includes/db_vars.inc';
include 'classes/sessions.php';
/**************************************************
*
* DISPLAY THE LOGIN PAGE
*
**************************************************/
//check to see if this form has already been submitted
if (!isset($_POST['submitOk']))
{
?>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="width: 50%;padding-right: 25px; padding-left: 25px; padding-top: 15px;" align="left">
<span class="redTextLg">WELCOME.<br /></span>
<span class="blackTextMd">Hello and welcome to
XXXXXX, the continuing adventures of XXXXXXX. Our site requires a username and
password. If you have an account please enter your e-mail and password to the right. If you are new to
the site, please take a few minutes to <a class="blackTextMd" href="index.php?module=Utilities&page=Register">register</a>.</span>
</td>
<td align="left" style="width: 50%; vertical-align: top; padding-right: 25px; padding-left: 15px; padding-top: 25px;border-color:#999999;border-top-width:0px;border-bottom-width:0px;border-left-width: 1px;border-right-width:0px; border-style:solid;">
<form method="Post" action="index.php">
<span class="name_text">Login. <br/><br /></span>
<a class="label">e-mail:</a> <br />
<input class="login_field" type="text" name="email" />
<br/>
<br/>
<a class="label">password: </a><br/>
<input class="login_field" type="password" name="pwd" />
<br/>
<br/>
<input class="login_button" type="submit" name="submitOk" value="Sign in">
</form>
<a class="blackTextMd" href="index.php?module=Utilities&page=ForgotPassword">Don't know your password?</a>
</span></p>
</p>
</td>
</tr>
</table>
<?php
}else{
// Connect to MySQL
ini_set("error_reporting",E_ALL);
$db = &new MySQL($host, $dbUser, $dbPass, $dbName);
// Make connection to MySQL server
if (!$dbConn = mysql_connect($host, $dbUser, $dbPass)) {
//trigger_error('Could not connect to server: ' . mysql_error());
die();
}
// Select the database
if (!mysql_select_db($dbName)) {
//trigger_error('Could not select database: ' . mysql_error());
die();
}
$emailAddress = trim(mysql_escape_string($_POST['email']));
$password = trim(mysql_escape_string($_POST['pwd']));
$sql= "SELECT *
FROM
tableX.columnX
WHERE
emailaddress = '$emailAddress'
AND
password = md5('$password')
AND
statusid='1'";
// Run the query, identifying the connection
if (!$queryResource = mysql_query($sql, $dbConn)) {
trigger_error('Query error ' . mysql_error() . ' SQL: ' . $sql);
}
$result = mysql_query ($sql);
if (mysql_num_rows($result)!=FALSE)
{
while ($row = mysql_fetch_array($result))
{
$userid = $row['userid'];
$isLoggedIn = '1';
$session = new Session();
$session->set('userid',$userid);
$session->set('emailAddress',$emailAddress);
$session->set('password',$password);
$session->set('isLoggedIn',$isLoggedIn);
$sid = session_id();
$session->set('sid',$sid);
header('location: modules.php?module=Home');
}
}else{
header('location: index.php?errorCode=AuthenticationError');
}
}
?>