header problem

Posted on 2009-02-08
Last Modified: 2012-05-06
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


$to = "";

$subject = $_POST["email_subject"];

$message = $_POST["email_msg"];

$from = $_POST["email_email"];

$headers = "From: $from";

$domail = mail($to,$subject,$message,$headers);


	header('Location: contacthanks.php');


	echo "not ok";



Open in new window

Question by:derrida
    LVL 27

    Expert Comment

    This error usually means that you have a blank line at the beginning of your script.  If so, remove it.
    LVL 15

    Expert Comment


    what's the file type? plain text/UTF8 ?
    if UTF8, it's mostly because of the byte order mark cause.
    please read id 23333523
    LVL 18

    Accepted Solution

    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:
     Although I would recommend correcting the problem rather than working around it by using buffering.

    LVL 1

    Author Closing Comment


    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    A colleague recently asked me about how to give his client a small part of the web site that could be completely under the client's control.  Since I have done this sort of thing before to add emergency banners to a web site, I decided I would creat…
    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to dynamically set the form action using jQuery.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now