The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

[Solved] PHP Form not linking to thank you page

  • # September 9, 2009 at 9:11 am


    I am virtually clueless where PHP is concenned and I was hoping someone would be able help me solve a problem with the response form that I currently have on my website.

    When the form is filled in and "submit" is clicked – I get this message in the browser:

    Warning: Cannot modify header information – headers already sent by (output started at /home/graphi31/public_html/response.php:12) in /home/graphi31/public_html/response.php on line 28

    What is supposed to happen is that it should show a thank you page – thanks.html which is in the directory, as it has always been.

    Oddly, this did not happen before, the only recent change I can think of is that I have changed my hosting to JustHost.

    I’d be most grateful for any advice on how to fix this as it is driving me nuts.

    Thanks in advance…


    My Contact page address is

    The PHP for the response form looks like this:

    // Configuration Settings
    $SendFrom = "Graphic Alchemy <>";
    $SendTo = "";
    $SubjectLine = "Portfolio Response";
    $ThanksURL = "thanks.html"; //confirmation page

    // Build Message Body from Web Form Input
    foreach ($_POST as $Field=>$Value)
    $MsgBody .= "$Field: $Valuen";
    $MsgBody .= "n" . @gethostbyaddr($_SERVER["REMOTE_ADDR"]) . "n" .
    $MsgBody = htmlspecialchars($MsgBody, ENT_NOQUOTES); //make safe

    // Send E-Mail and Direct Browser to Confirmation Page
    mail($SendTo, $SubjectLine, $MsgBody, "From: $SendFrom");
    header("Location: $ThanksURL");

    # September 9, 2009 at 12:39 pm

    This is what you want:

    header(“Location: ” . $ThanksURL);
    # September 9, 2009 at 3:37 pm

    Thanks for your help Doc.

    I tried this code but it still gives the same error message.


    # September 9, 2009 at 3:44 pm

    Hmmmm. You haven’t changed the PHP at all? Not a single line?

    # September 9, 2009 at 4:56 pm

    This reply has been reported for inappropriate content.

    do this instead:

    print “”;
    # September 10, 2009 at 2:36 am

    Thanks ikthius,

    That did the trick perfectly.



    # September 10, 2009 at 2:44 am

    This reply has been reported for inappropriate content.

    no problem…. glad you got it working

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed