• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

header problem

Hi
i have a contact form. when i send it i get:
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\or_02\contact.php:290) in C:\wamp\www\or_02\contact.php on line 376

this is the most basic things.
the code is attached.

best regards

ron
if(isset($_POST['submit'])){
$to = "me@gmail.com";
$subject = $_POST["email_subject"];
$message = $_POST["email_msg"];
$from = $_POST["email_email"];
$headers = "From: $from";
$domail = mail($to,$subject,$message,$headers);
 
if($domail){
	header('Location: contacthanks.php');
}else{
	echo "not ok";
}
 
}

Open in new window

0
derrida
Asked:
derrida
1 Solution
 
Cornelia YoderArtistCommented:
This error usually means that you have a blank line at the beginning of your script.  If so, remove it.
0
 
fsze88Commented:
derrida,

what's the file type? plain text/UTF8 ?
if UTF8, it's mostly because of the byte order mark cause.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_24037516.html
please read id 23333523
0
 
Hube02Commented:
The error tells you exactly where to start looking for the problem

 "(output started at C:\wamp\www\or_02\contact.php:290)"

Look on like 290 of contact.php. You will likely find that you have already sent something to the browser. This could simply be a blank line, or you may have already started sending output of some kind (i.e. HTML).

When redirecting a browser you need to make sure that any code that needs to determine if a redirect is in order is done before any HTML is sent. Or, you can use a buffer:

http://us.php.net/outcontrol
http://www.codewalkers.com/c/a/Miscellaneous/PHP-Output-Buffering/
 
 Although I would recommend correcting the problem rather than working around it by using buffering.

0
 
derridaAuthor Commented:
thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now