Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error when changing Header

Status
Not open for further replies.

Nightsoft

Programmer
Aug 23, 2001
50
DK
Im writing a simple mailform for a homepage and when it runs it and the mail is sent I wan't to changer the header to another page, that writes that the letter has been sent.
The problem is that when I try to change the Header it comes with the following error :

Warning: Cannot add header information - headers already sent by (output started at /home/ in /home/ on line 40


I havn't change the header yet!!??
What's going on
My code looks (simplified) like this :
Code:
<?php
/* This is my line 1.*/
Code:
require &quot;menu.php&quot;;

$content = &quot;&quot;;
$error = &quot;&quot;;

if ($ditnavn){
$mailrecepient = &quot;$modtnavn <$modtmail>&quot;;
$mailsubject = &quot;Tilmelding til \&quot;$forkortelse\&quot;&quot;;
$mailbody = &quot; $ditnavn har tilmeldt sig $betegnelse
$mailfrom = &quot;From: $ditnavn <$dinemail>\r\nReply-To: $dinemail\r\nReturn-Path: $dinemail&quot;;
/* some kode here (Simplified) */
Code:
mail($mailrecepient, $mailsubject, $mailbody, $mailfrom);
/* This is where it won't do it. My line 40*/
Code:
header(&quot;Location: [URL unfurl="true"]http://www2.spejdernet.dk/udd/emailsendt.php?modtnavn=$modtnavn&quot;);[/URL]
	exit;
}
?>

Why won't it change it?
Machine code Rocks:)
 
Make sure that there is NO white space/free blank lines after the ending ?> php tag, that will cause the problem.
Regards,

Chris Murley
Systems Administrator\Programmer
 
Hi Chris!

It worked. But then i got another error about the same, just in my line 9. In my line 9 i had one echo.
So i removed it and it worked.
My thought are that when i did a echo, it makes a page and automaticly makes a header info.
And header info on one page apparently can't be changed when it is loaded.

A'm I right.? Machine code Rocks:)
 
Yes, if you intend to use Header() you cannot echo any output before it. :) Regards,

Chris Murley
Systems Administrator\Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top