Results 1 to 3 of 3

Thread: Redirect after form submit

  1. #1
    Join Date
    Jul 2008
    Posts
    134
    Thanks
    13
    Thanked 1 Time in 1 Post

    Default Redirect after form submit

    I have a jquery form which displays the following above my form after the form is successfully processed.
    Code:
    <div class="success">Thank you. Membership form submitted!</strong> </div>
    and is only displayed after MailHandler.php processes the data (just grabs all the post inputs and emails the specified user.

    Once the form handler sends the email behind the scenes it shows the success message.

    I need to redirect to the payment page after the form processes, and of course if I add a meta refresh url redirect in the form page it automatically redirects prior to the form being submitted.

    I think the logic needs to be something like if referrer is MailHandler.php then redirect, but I'm not sure how to do this.

    Thank you for any help.
    Last edited by ?foru; 03-28-2014 at 03:39 AM.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,935
    Thanks
    16
    Thanked 303 Times in 302 Posts
    Blog Entries
    11

    Default

    Header redirect on successful form submit http://www.php.net/manual/en/function.header.php - at the point in the PHP where the thanks message is generated.

    Not as elegant, but you could also echo a meta refresh into the page at the same point as above;
    Code:
    echo "<meta http-equiv='refresh' content='=3;payment.php' />";
    Or echo a redirect JavaScript;
    Code:
    echo "<script>top.location = 'payment.php';</script>";
    Or echo a redirect with pause (3 seconds example);
    Code:
    echo "<script>setTimeout('top.location = \'payment.php\'', 3000);</script>";
    If you need more help, please post a copy of the MailHandler.php script.
    Last edited by Beverleyh; 03-25-2014 at 08:50 AM. Reason: code samples added
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. #3
    Join Date
    Jul 2008
    Posts
    134
    Thanks
    13
    Thanked 1 Time in 1 Post

    Default

    Thank you for the reply. I made the mistake of adding the redirect code to MailHandler.php, but I needed to add it to payment.js which uses ajax to check the form on the spot. I searched through and found the "success" portion of the code and added...

    Code:
    setTimeout('top.location = \'payment.php\'', 9000);
    9000 is the timeout for the thank you display message, so it now shows that then it redirects.

Similar Threads

  1. Help with form redirect after submit.
    By missileman in forum HTML
    Replies: 1
    Last Post: 01-08-2013, 03:43 PM
  2. Replies: 1
    Last Post: 03-22-2011, 11:02 PM
  3. Replies: 0
    Last Post: 03-24-2010, 02:54 PM
  4. Form action Mailto need to open new page on submit and submit email
    By lstammer in forum Looking for such a script or service
    Replies: 0
    Last Post: 12-06-2007, 04:41 PM
  5. Validate and redirect form submit
    By vicksm in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 06-28-2005, 06:59 PM

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
  •