php - Redirect a user back to the page they where on before submitting the form -
i user redirect page on before submitting contact form, after have landed on thank you page on wordpress site.
when user submits form, form redirects thank you page.
on thank you page, redirected page on before submitted contact page.
main contact form
thank page
redirect user page before contact page
if create variable , store refer contact us page:
$referer = $_server['http_referer'];
then carry on thank you page
if ($referer == '/contact-us');
when on thank you page, want redirected after 4 seconds page on, before submitted form on contact page.
use either header() or meta refresh on thank page.
header("refresh:5;url=" . $_server['http_referer']);
or
<meta http-equiv="refresh" content="5; url=<?php echo $_server['http_referer']; ?>">
i advise checking on server['http_referer'] before using method little flaky.
Comments
Post a Comment