Topic: Output error while sending headers (Read 1282 times)
Atari ST fan
Posts: 7
48 credits Members referred : 0
« on: Nov 26, 2006, 11:48:42 PM »
I am using Simple form mail ver. 1.11. The form is at www.bushbuckadventures.com/booking.html It produces this error message: "Warning: Cannot modify header information - headers already sent by (output started at /home/content/b/u/s/bushbuck/html/booking2.php:2) in /home/content/b/u/s/bushbuck/html/booking2.php on line 20"
Line 20 appears to be this: header("Location: ".$goto_after_mail);
It's supposed to direct it to thankyou.html
Otherwise the script works - it sends the right information to my email address.
Please advise. Thanks. -s
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 8132
41749 credits Members referred : 3
Re: simple mail script
« Reply #1 on: Nov 26, 2006, 11:56:25 PM »
This error is because you output information, and then send headers.
Atari ST fan
Posts: 7
48 credits Members referred : 0
« Reply #4 on: Nov 27, 2006, 12:31:08 AM »
I hope we are both talking about the same script! It is posted here: http://www.finalwebsites.com/snippets.php The only change I made was to put my email address instead of you@yourmail.com and the name of the goto page which is thankyou.html I don't know what change I should make to stop the error message. -s
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 8132
41749 credits Members referred : 3
« Reply #5 on: Nov 27, 2006, 12:49:28 AM »
The script doesn't really matters as the error is this.
There is something printed in the browser before the error.
Atari ST fan
Posts: 7
48 credits Members referred : 0
« Reply #6 on: Nov 27, 2006, 01:17:46 AM »
Sorry, I have no idea what you mean! -s
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6357
38966 credits Members referred : 374
It's time to use PHP5!
« Reply #7 on: Nov 27, 2006, 10:19:05 AM »
this is the part from the manual where this is about:
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
Code:
<html> <?php /* This will give an error. Note the output * above, which is before the header() call */ header('Location: http://www.example.com/'); ?>
Atari ST fan
Posts: 7
48 credits Members referred : 0
« Reply #8 on: Nov 28, 2006, 04:24:55 AM »
So are you saying that the way I am calling the php script from my html form page is incorrect? Specifically that this line: <form action="booking2.php" method="post" name="booking form"> is incorrect or in the wrong place? -s
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6357
38966 credits Members referred : 374
It's time to use PHP5!
« Reply #9 on: Nov 28, 2006, 08:16:26 AM »
it's about sending html ouput before the calling the function "header" (don't understand why the last example is not clrear)
Atari ST fan
Posts: 7
48 credits Members referred : 0
« Reply #10 on: Nov 28, 2006, 09:00:43 AM »
Your last example was clear - it just doesn't relate to my situation - I don't have a single PHP/HTML file. I have an html page (booking.html) and a php file (booking2.php) that is called as the action for submitting the form. I don't see where I am sending html output before calling the function "header". What happens before the function "header" is called is that the mail is sent. -s
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6357
38966 credits Members referred : 374
Your last example was clear - it just doesn't relate to my situation - I don't have a single PHP/HTML file. I have an html page (booking.html) and a php file (booking2.php) that is called as the action for submitting the form. I don't see where I am sending html output before calling the function "header". What happens before the function "header" is called is that the mail is sent. -s
do you use echo before the header? (its also html output)
Atari ST fan
Posts: 7
48 credits Members referred : 0
« Reply #12 on: Nov 29, 2006, 07:36:39 AM »
I'm using the script as posted here: <http://www.finalwebsites.com/snippets.php?id=3> There is no "echo". I'm using the form as posted here: <www.bushbuckadventures.com/booking.html> There is no "echo" in the form. -s
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6357
38966 credits Members referred : 374
It's time to use PHP5!
« Reply #13 on: Nov 29, 2006, 09:27:29 AM »
post the code until row 20 from this file booking2.php