28, May 2012

Output error while sending headers - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Output error while sending headers
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: Output error while sending headers  (Read 2321 times)
Atari ST fan
*
Posts: 7
48 credits
Members referred : 0


« on: Nov 26, 2006, 10: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: Male
Posts: 5799
46391 credits
Members referred : 3



Re: simple mail script
« Reply #1 on: Nov 26, 2006, 10:56:25 pm »

This error is because you output information, and then send headers.

Headers should be send before output.

Check the documentation here

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #2 on: Nov 26, 2006, 11:15:33 pm »

The problem is before that line.

There is something printed before that.

That should be removed.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Nov 26, 2006, 11:28:30 pm »

Hey Nick you answered this thread already thanks! Wink

Atari ST fan
*
Posts: 7
48 credits
Members referred : 0


« Reply #4 on: Nov 26, 2006, 11:31:08 pm »

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: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #5 on: Nov 26, 2006, 11:49:28 pm »

The script doesn't really matters as the error is this.

There is something printed in the browser before the error.

That should be removed.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Atari ST fan
*
Posts: 7
48 credits
Members referred : 0


« Reply #6 on: Nov 27, 2006, 12:17:46 am »

Sorry, I have no idea what you mean!
-s
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Nov 27, 2006, 09: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, 03: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: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #9 on: Nov 28, 2006, 07: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, 08: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: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #11 on: Nov 28, 2006, 08:12:36 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

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, 06: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: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #13 on: Nov 29, 2006, 08:27:29 am »

post the code until row 20 from this file booking2.php

Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #14 on: Nov 29, 2006, 08:29:10 am »

I think there is some whitespace (which is out too!)

Atari ST fan
*
Posts: 7
48 credits
Members referred : 0


« Reply #15 on: Dec 01, 2006, 05:40:51 am »

Thank you all for your help - I found an empty line above the "<?php" - it's fixed now and all working well.
-s
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=4948
Tags : php html browsers email Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Output error while sending headers
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 04:45:29 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.