Results 1 to 4 of 4

Thread: php contact form with no thank you

  1. #1
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default php contact form with no thank you

    I have a feeling this is a simple fix, but I am having some trouble with this one. I have a contact form that I do not want going to a "thank you" page.

    Here is the code I am using on the php sending page
    PHP Code:
    <?php
    $headers  
    "MIME-Version: 1.0\r\n"
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

    $name $_REQUEST['name'];
    $email $_REQUEST['email'];
    $message $_REQUEST['message'];
    $to "xxxx@xxxx.com";
    $ToName "My Name";
    $date date("m/d/Y H:i:s");
    $ToSubject "Email From $name";
    $EmailBody "Sent By: $name at $email
                <br /><br />
                Message Sent:
                <br />
    $message<br /><br />";  
    $message $EmailBody.$EmailFooter;
    mail($to$ToSubject$message$headers "From:$name <".$email.">");
    header("Location:thankyou.html");

    ?>
    I pulled out [header("Location:thankyou.html");] but when I hit the submit button the page opens my send.php page.

    I want to be able to hit the submit button and just have the data pass to email without the form page changing as I am usng jQuery to change the div contents. *The site is a single page with jQuery for scrolling.

    If anyone knows how to stop the page from changing when I hit submit, that would be great.

    *Note: I did try changing 'thankyou.html' to the current page name, but since it is a single page with animated scroll it refreshes the whole page so the jQuery div change doesnt apply and the form resests.

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    The form will need to reload to process this unless you send it as an ajax request. Commenting/removing the header line should leave you on the page you are sending the email on.
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Yes, use ajax for this. Post your entire code (the form HTML as well).
    - Josh

  4. #4
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default

    I tried removing the header line and it was then loading the php page that sends the form data so my site would jump from my site to a white page with the php code displayed. I just put the form in an iframe, much easier for me to work with and it works the way it should, with field validation checks and all.

Bookmarks

Posting Permissions

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