可能重复:
PHP 已发送的标头
好的,我收到此错误:
Warning: Cannot modify header information - headers already sent by (output started at
/home/content/91/9646291/html/quotesystem/cpanel/index.php:1) in
/home/content/91/9646291/html/quotesystem/cpanel/index.php on line 11
Notice: Undefined variable: content in
/home/content/91/9646291/html/quotesystem/cpanel/index.php on line 63
Warning: include() [function.include]: Filename cannot be empty in
/home/content/91/9646291/html/quotesystem/cpanel/index.php on line 63
Warning: include() [function.include]: Failed opening '' for inclusion
(include_path='.:/usr/local/php5_3/lib/php') in
/home/content/91/9646291/html/quotesystem/cpanel/index.php on line 63
这是页面上的代码:
//Check USER LOGIN IF not logged in bring to login screen else display content
if (!(checkUser())){
header('Location: /quotesystem/index.php');
}else{
//Get the user array to display data
$userArray = getUserArray();
//Make sure that the userid in the browser is the same as current loggin in user
if($userArray['user_id'] != $uid){
$content = '';
$view = (isset($_GET['view']) && $_GET['view'] != '') ? $_GET['view'] : '';
switch ($view) {
case 'list' :
$content = 'list.php';
$pageTitle = 'Customer Control Panel - View Product';
break;
case 'changepass' :
$content = 'includes/changePass.php';
$pageTitle = 'Customer Control Panel - Change Password';
break;
case 'modify' :
$content = 'includes/modify.php';
$pageTitle = 'Customer Control Panel - Modify Product';
break;
case 'detail' :
$content = 'detail.php';
$pageTitle = 'Customer Control Panel - View Product Detail';
break;
default :
$content = 'main.php';
$pageTitle = 'Customer Control Panel - View Info';
}
if(!($content) OR $content =='') {
$content = 'main.php';
$pageTitle = 'Customer Cpanl';
}
}else {
echo "Sorry this is for the customer's eyes only...you are being redirected to the <a href=\"http://www.domain.com/quotesystem\">homepage</a>. ";
}
}
include $content;
include('../admin/footer.php');
?>
流程如下:如果用户已登录(如果未登录,checkUser() 返回 true,如果未登录,则返回 true),如果当前用户 id 与 url 中的用户 id 匹配,则会显示内容。如果不是,它会显示一条消息并重定向。