0

I searched on the various solutions with respect to my question about redirecting to a different webpage - both on this site and google.com, but I can figure out why i keep getting the error in my specific scenario -

the error being: : "Warning: Cannot modify header information - headers already sent by (output started at test_ecis_lib_pdo.php:3) in login_submit3.php on line 10".

The code of login_submit3.php:

<?php
//! include config file; includes session_start() and ecp php library
include 'config.php';

if(DBLoginSubmitA($mysql_hostname, $mysql_username, $mysql_password,$mysql_dbname))
{ 
 //redirect to webpage depending on SESSION paramter ['customertype'
 switch($_SESSION['customertype'])
 {
case 'member':
    header("location:members3.php",true,'301');
    die(); 
    break;
case 'admincrm':
    header("location:admincrm3.php"); 
    die();
    break;
default:
    break;
 }

};

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PHPRO Login</title>
</head>

<body>

</body>
</html>

The code of config.php:

/*** begin our session ***/
session_start();

//! include lib after session_start()
include 'test_ecis_lib_pdo.php';

/*** mysql hostname ***/
$mysql_hostname = 'localhost';

/*** mysql username ***/
$mysql_username = 'root';

/*** mysql password ***/
$mysql_password = 'xxxx';

/*** database name ***/
$mysql_dbname = 'xxx';

?>

The code of test_ecis_lib_pdo.php (a library with functions - and where the error refers to) starts with:

<?php
//GLOBAL VARIABLES
$error = "no error";
$timezone = date_default_timezone_set("Europe/Amsterdam");
$CUSTOMER_TYPE=array(
  "interested"=>"1",
  "member"=>"2",
  "chair"=>"3",
  "admincrm"=>"4",
  "adminfinance"=>"4",
  "adminenergymanagement"=>"5"
);

I checked that the test_ecis_lib_pdo.php file does not send send any tags or echo text before calling header() but i still get the error - where do i go wrong??? Please your help.

4

2 回答 2

1

一、使用

header("location: admincrm3.php"); 

代替header("location:admincrm3.php");

第二,你的编码是什么?如果utf-8 可以肯定utf-8 without BOM

并确保之前没有空格或其他文本<?php

如果您想在发送之前放置文本,请header使用ob_start()andob_flush()

于 2013-06-21T16:56:36.047 回答
0

我不确定您的包含中发生了什么,但您可能需要查看输出缓冲——如果您在数据已经发送到缓冲区之后尝试发送标头,您将收到该错误。

于 2013-06-21T16:56:19.880 回答