Log in

View Full Version : Resolved Redirect after form submit



?foru
03-25-2014, 04:28 AM
I have a jquery form which displays the following above my form after the form is successfully processed.

<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.

Beverleyh
03-25-2014, 08:36 AM
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;
echo "<meta http-equiv='refresh' content='=3;payment.php' />";
Or echo a redirect JavaScript;
echo "<script>top.location = 'payment.php';</script>";
Or echo a redirect with pause (3 seconds example);
echo "<script>setTimeout('top.location = \'payment.php\'', 3000);</script>";

If you need more help, please post a copy of the MailHandler.php script.

?foru
03-28-2014, 03:29 AM
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...


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