简体   繁体   中英

How to redirect opt-in form to thank you page?

I'm trying to figure out how to redirect my opt-in form to a specific page ( http://www.example.com/thanks )

Here's the code for my form:

<form action="http://mailer334.insty.me/subscribe" method="POST" accept-charset="utf-8">
<label for="name">Name</label><br/>
<input type="text" name="name" id="name"/>
<br/>
<label for="email">Email</label><br/>
<input type="text" name="email" id="email"/>
<br/>
<input type="hidden" name="list" value="efwefwefwefwefwef"/>
<input type="submit" name="submit" id="submit"/>
</form>

Right now it's just taking people to the default page for Insty.me ( http://mailer359911.insty.me/subscribe ) which isn't what I want it to do - it need to post information to that page to add people to my email list, but redirect to a different page thanking them and giving further instructions.

Create a wrapper php script on your domain that receives the form info and then post to the third party via CURL. Then do the redirect using

header("Location: http://www.mysite.com/thanks");

You might be thinking on submitting the form using ajax and then redirect, but that will be impossible because the SAME ORIGIN POLICY enforced by the browsers as a security rule. You cannot run ajax request against a different domain. On a phonegap application you might override this behavior , but on a standard web app that is intended to be open on regular browsers is not possible.

<?php 
  if(!isset($_POST['submit'])) { 
?>

<form action="http://mailer334.insty.me/subscribe" method="POST" accept-charset="utf-8">
  <label for="name">Name</label><br/>
  <input type="text" name="name" id="name"/>
<br/>
  <label for="email">Email</label><br/>
  <input type="text" name="email" id="email"/>
<br/>
  <input type="hidden" name="list" value="efwefwefwefwefwef"/>
  <input type="submit" name="submit" id="submit"/>
</form>

<?php 
   } else { 
     include 'thanks.php';
} ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM