Warning: Cannot modify header information

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
akkad
Forum Newbie
Posts: 14
Joined: Tue Jul 31, 2007 4:09 am

Warning: Cannot modify header information

Post by akkad »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi everybody ; this is what i am getting when loading the page traffic.html , in the frame body.php:

Warning: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/xampp/thesis/admin/body.php:2) in /opt/lampp/htdocs/xampp/thesis/admin/body.php on line 64

Warning: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/xampp/thesis/admin/body.php:2) in /opt/lampp/htdocs/xampp/thesis/admin/body.php on line 65

Warning: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/xampp/thesis/admin/body.php:2) in /opt/lampp/htdocs/xampp/thesis/admin/body.php on line 66

Warning: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/xampp/thesis/admin/body.php:2) in /opt/lampp/htdocs/xampp/thesis/admin/body.php on line 67

Warning: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/xampp/thesis/admin/body.php:2) in /opt/lampp/htdocs/xampp/thesis/admin/body.php on line 68

though i am not ouputting anything before these lines .

Code: Select all

if(($day == "- Day -") && ($month == "- Month -") && ($year != "- Year -"))
{
$date=$year;             
	setcookie("day",$day); // line 64
                setcookie("month",$month); // 65
                setcookie("year",$year);//66
                setcookie("first_param", $first_param);//67
	setcookie("second_param", $second_param);//68
	
echo shell_exec("cat `bash ./cal $date` | grep $first_param  | /usr/bin/perl   /opt/lampp/htdocs/xampp/thesis/calamaris/calamaris -a -P 60 -T 0 -r 400 -d 500 -u -O -F html");
				
}
and when i am printing the cookies:
<code>

Code: Select all

print_r($_COOKIE);
</code>
it is outputing :
Array ( [PHPSESSID] => 443d8ad87a1817c428b5ba4f86ffe92a )

i would like to mention that this page is called after authentication and using header function to call it in the auth.php page:
<code>

Code: Select all

<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', True);

#echo $_POST['security_code'];
$userid=$_POST['userid'];
#echo $userid;
$password=$_POST['password'];
$server="10.2.0.12";        //change to ip address of ldap server
$basedn="OU=EDU,DC=academic,DC=aua,DC=am";       //change to reflect the ou and domain that your users are in.
#$script=$_SERVER['SCRIPT_NAME'];

   
   

                if ( ($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) && (isset($userid)) && (isset($password))) 
                {
                        
                	 $filter="CN=$userid";
                        #$filter="(&(|(!(displayname=Administrator*))(!(displayname=Admin*)))(cn=$username))"; 
                               //define an appropriate ldap search filter to find your users, and filter out accounts such as administrator(administrator should be renamed anyway!).
                        $dn = "CN=$userid";
                                if (!($connect = ldap_connect($server))) {
                                        exit(0);
                                }
                                # echo" after second connect";
                                if (!($bind = @ldap_bind($connect,"$dn,"."$basedn",$password)))
                                 {
                                    header("Location:newlog.php");
                                       
                                 	 exit(0);
                                }
                                
                                  #echo" after second bind";
                $sr = ldap_search($connect, $basedn,$filter);
                $info = ldap_get_entries($connect, $sr);
                if(!$sr)
	{    
		
		header("Location:newlog.php");
		#print "<br>anonymous search failed";
		exit(0);
	}
	if($info["count"] == 0)
	{   
		header("Location:newlog.php");
		#print "<br>User unknown";
		exit(0);
	}
	if($info["count"] > 1)
	{
		header("Location:newlog.php");
		#print "<br>More than one such user - report to CITS";
		exit(0);
	}
                #$fullname=$info[0]["displayname"][0];
                $fullname=$info[0]["givenname"][0]." ".$info[0]["sn"][0];
               #echo $fullname;
               # $fqdn=$info[0]["dn"];
                #echo $fqdn;
                
                #echo "<br>";
			    $id =$info[0]["telephonenumber"][0];
			   # echo $id;
			   # echo "<br>";
			    $mail= $info[0]["userprincipalname"][0];
			    #echo $mail;
			   # echo "<BR>";
			  	#print_r($_SERVER[SERVER_ADDR]);
			  	$d=date("Y-m-d H:i:s");
			  	#echo "<BR>";
			  	#echo $d;
                #setcookie("user",$userid);
                #setcookie("token",$password);
                #setcookie("fullname",$mail);
                #setcookie("fqdn", $id);
                
                header("Location:traffic.html");
                
        } else {
       #header('Refresh:1;newlog.php');
       header("Location:newlog.php");
        #die();
       # echo "oops!";
        }
		
?>
</code>


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Warning: Cannot modify header information

Post by superdezign »

akkad wrote:though i am not ouputting anything before these lines .
Are you sure? What is line 2 of thesis/admin/body.php?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

akkad - Please use the appropriate syntax tags when posting code. Please edit your post to reflect this.

Here is an example..

Code: Select all

#echo $_POST['security_code'];
$userid=$_POST['userid'];
#echo $userid;
$password=$_POST['password'];
$server="10.2.0.12"; //change to ip address of ldap server
$basedn="OU=EDU,DC=academic,DC=aua,DC=am"; //change to reflect the ou and domain that your users are in.
#$script=$_SERVER['SCRIPT_NAME']; 
Post Reply