There is a problem in my drupal intranet that when i loggin or logout or post any requests or fill up any forms, when action is happened, then the page comes blank. The Page hangs. The type of url that comes after i logout is


and the type of url that i get in login is

and when i refresh the page afterwards, the page becomes fine but i have to do it all the time.

The Error Showing is

Cannot modify header information - headers already sent by (output started at ..........)

Is there any solution that i can overcome with?
Plz, can anybody help me out with this.

Thank You


apsivam’s picture

have you edited any php file by hand?
this will usually happen when you accidentally left a blank space before <?php in any file. check for this.

Sivanandhan, P. (a.k.a. apsivam)

yubaraj’s picture


The problem is now no longer. It was the same problem that u have mentioned.

ehowland’s picture

This can also happen at the end of the file after the ?> at the end of the file.

I believe this can be any whitespace (both lines and spaces).

It thinks you are tying to add more text to the output.

See also


pmaster4’s picture

I created a module and was getting a similar problem Thanks whiteowl

sahar999’s picture

Great post, Thank you.

Jay Armstrong’s picture

Fixed it.

I had left a blank line in between some php & HTML code -- it looked like every other blank line, but this one had a number of spaces. Took it out and no more problems. :)

Jay Armstrong’s picture

Changed to a different theme, and added some custom content from my desktop, and FTP'd to the server. I started having the same header issues and/or pages would simply load blank anytime I was POSTing input (filling in forms and hitting 'save', for example). I kept checking my customized files for spaces, but they were clean. Turns out the php file was getting modified during or after uploading it to the server. I edited it directly on the server using 'file manager' in cpanel and found the following at the very top of the file:


That extra code doesn't show up in Notepad, MS Expression 12.0, or Editplus 2.31, but I can see it on the server and in Editplus 1.25. In other words, most of my editors show the first line as <?php Odd.

Point: check that your editor isn't jacking up your php files without telling you.

archard’s picture

Well I'll be damned. I was having the same issue and was pulling my hair out as to why this issue was coming up and my editor was doing the same thing by putting the  thing in front of the <?php at the top of my template.php file. I'm glad I came across this topic.

TPerkins’s picture

I was about ready to kill myself. Every time I would a section of code to my template.php I would get  above whatever it was overriding. Went into cPanel and behold there it was.

Thank you!!!

hargobind’s picture

So glad I found this post. All my code looked fine locally, but once I uploaded it to the server, I started seeing this error on the server.

The characters you are describing is caused by the Byte Order Mark (BOM) in Unicode. I looked back at the file encoding and found it had been converted to UTF-8. I switched out the encoding, reuploaded, and the errors went away.

For more information on the Unicode BOM:

al_au’s picture

Great post! I had a problem wherby anonymous users would get a blank page after submitting a form i.e. after logging in, or conducting a search.

Anyway I just had to get rid of some spaces before <?php and voila :)


Caderial’s picture

Hey Guys and Gals Im having the same issue, when i edit a node say

and then i save the node with via the save button at the bottom it loads a white page this page's url is the same as above

But nothing is showing , its not redirecting myself or the editor to the content it just loads the blank page.

I leapt into my tpl files and my template.php file to look for spaces in the code prior to <?php tags but there are no spaces. when i go to my log i get these errors

php 05/11/2009 - 09:53 Cannot modify header information - headers ... admin

and in detail it sais

Type php
Date Monday, May 11, 2009 - 09:53
User admin
Message Cannot modify header information - headers already sent by (output started at /home3/mysite/public_html/lizzylee/themes/lizzylee/template.php:15) in /home3/artemisb/public_html/lizzylee/includes/ on line 328.
Severity error
Hostname (hidden for security reasons)

I don't get whats causing the problem , any suggestions?...

hendrinx’s picture

I reckon I added this when I was on a tidy up... not sure why this needs to be omitted off the template.php file - but it is and it works.

Toxid’s picture

I had added some custom php code in the top of template.php, and made a blank line before the next <?php. I deleted that line and now it works great! Thanks!

theropodx’s picture

Yup, that solved it for me too. Problem was in template.php. Extra spaces at the end so I just removed the ?> at the end of the doc and all is fine. Read somewhere that drupal standard is just to leave that bit off anyway.


asabird’s picture

Thank you guys. I had mistakenly pasted a whole line on top of my php file and everytime I was logging in the line would show up on top of my site. I was about to go crazy but thanks God I came across this posting

digitalpbk’s picture

There are numerous different ways to overcome this problem,
I have posted a full list at Solve "Cannot modify header information".

aschiwi’s picture

This not only happens when you have a blank space before your opening php tag or have included a closing php tag at the end of template.php. It also happens when template.php has utf-8 encoding (might not be true all the time but it was true for my template.php)

Anonymous’s picture

This solved things for me. Giving it an ANSI encoding fixed things.

zps’s picture

Worked for me.

iandickson’s picture

Also worth running phpmyadmin to check your tables and then repair errors.

Worked for me after my server fell over, and I knew that no changes had been made to any php files (though of course I checked all the last mod dates first, just in case).

joelbox-Mondial-IT’s picture

Perhaps someone could post a grep statement to detect the situation? I am having some trouble finding who the culprit is.

madman99’s picture

¡ve been getting the headers already sent a lot lately on webpages that i havent changed in ages. on this code

if (isset($_COOKIE["myuniqueid"]))
	$my_uniqueid = $_COOKIE["myuniqueid"];
	$my_uniqueid = rand(111111111,999999999);

clerly the setcookie line causing the problem
I do all my html / php using notepad, never anything different. during 15 years.

today out of curiosity i opened one of my files with wordpad, checked there wasnt a space before the <?php and saved it, up'loaded it to the server and the problem was gone.