Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Send to thankyou page after form submit

    I have this at the bottom of the page and there i would like to redirect to thankyou page tried using header('thankyou.html....

    <?php
    } else {
    error_reporting(0);

    if (mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n"))

    //Message sent!
    //It the message that will be displayed when the user click the sumbit button
    //You can modify the text if you want
    echo nl2br("
    <div class=\"MsgSent\">
    <h1>Congratulations!!</h1>
    <p>Thank you <b><?=$name;?></b>, your message is sent!<br /> I will get back to you as soon as possible.</p>
    </div>
    ");

    else

    // Display error message if the message failed to send
    echo "
    <div class=\"MsgError\">
    <h1>Error!!</h1>
    <p>Sorry <b><?=$name;?></b>, your message failed to send. Try later!</p>
    </div>";
    }
    ?>

  • #2
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    626
    Thanks
    51
    Thanked 67 Times in 67 Posts
    So... what exactly is the problem? Also, it would make things a lot easier to read if you could surround your php in php tags.
    "Yeah science!"

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,440
    Thanks
    62
    Thanked 537 Times in 524 Posts
    Quote Originally Posted by pdpascual View Post
    I have this at the bottom of the page and there i would like to redirect to thankyou page tried using header('thankyou.html....
    That won't work. You can't output a header after starting your output. You can only use the header() function BEFORE any output to the browser.

    I have a link in my signature about this (headers already sent), please read it.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •