我正在使用以下代码。我得到的错误:标题重定向和会话开始()生成错误
警告:不能更改头信息 - 头已经发出(输出开始/home/public_html/mc/cpanel/Source/verifylogin.php:11)
警告:在session_start() function.session启动]:不能发送会话cookie - 头已经发出(输出开始/home/public_html/mv/cpanel/Source/verifylogin.php:11)
警告:在session_start()[function.session -start]:无法发送会话缓存限制器 - 已发送的标头(输出开始于/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();
?>
我做了所有更改并减少了下面的代码,但仍无法正常工作。
<?php
ob_end_clean();
error_reporting(E_ALL^ E_NOTICE);
require("../Lib/dbaccess.php");
ob_start();
$inQuery="SELECT mhuserid, mhusername FROM cpanelusers WHERE mhusername = '".$_POST['UserName']."' AND mhpassword = '".hash('sha512', $_POST['Password'])."'";
try
{
$Result=dbaccess::GetRows($inQuery);
$NumRows=mysql_num_rows($Result);
if ($NumRows>0)
{
header("mainwindow.php");
}
else
{
header("index.html");
}
}
catch(exception $e)
{
}
?>
这必须是关于php的最常见问题 – Galen 2009-12-28 06:45:35
它显示了这些标题有多大的问题。 – RKh 2009-12-28 06:57:39