Header redirect and Session start() generating errors
- by RPK
I am using following code. I get errors:
Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/mc/cpanel/Source/verifylogin.php:11)
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/public_html/mv/cpanel/Source/verifylogin.php:11)
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/public_html/mv/cpanel/Source/verifylogin.php:11)
<?php
error_reporting(E_ALL^ E_NOTICE);
ob_start();
require("../Lib/dbaccess.php");
$inQuery = "SELECT mhuserid, mhusername FROM cpanelusers WHERE mhusername = '". $_POST['UserName'] ."' AND mhpassword = '". hash('sha512', $_POST['Password']) ."'";
try
{
$Result = dbaccess::GetRows($inQuery);
echo $Result;
$NumRows = mysql_num_rows($Result);
if ($NumRows > 0)
{
header("Location: http://www.example.com/cpanel/mainwindow.php");
session_start();
}
else
{
header("Location: http://www.example.com/cpanel/");
echo "Last login attempt failed.";
exit;
}
}
catch(exception $e)
{
}
ob_clean();
?>