I'm trying to create a form to signup for email subscription that goes out to exact target (our mailing service). Originally wanted the form to use ajax jquery and upon submit change the form to success message or error (depending on results). Learned that ajax form submits cannot be done outside of originating domain SOURCE
Question:
Trying to get this form to submit and append data to homepage url to display different content on load. There are three states
- Load form if GET is empty
- Load error message and form if GET signup=error
- Load success message if GET signup=success
<?php
if (empty($_GET)) {
echo'
<form action="emailhost.net/subscribe.aspx" name="subscribeForm" method="post" class="forms" id="form">
<input type="hidden" name="thx" value="example.com/?signup=success" />
<input type="hidden" name="err" value="example.com/?signup=error" />
<input type="text" name="Full Name" placeholder="Name" />
<input type="text" name="Email Address" placeholder="Email Address" />
<input type="submit" />
</form>'
;}
if(isset($_GET["signup"]) && trim($_GET["signup"]) == "error"){
echo '
<p>There was an error. Please try again</p>
<form action="emailhost.net/subscribe.aspx" name="subscribeForm" method="post" class="forms" id="form">
<input type="hidden" name="thx" value="example.com/?signup=success" />
<input type="hidden" name="err" value="example.com/?signup=error" />
<input type="text" name="Full Name" placeholder="Name" />
<input type="text" name="Email Address" placeholder="Email Address" />
<input type="submit" />
</form>'
;}
if(isset($_GET["signup"]) && trim($_GET["signup"]) == 'success'){
echo'
<p>Thank you for signing up!</p>'
;}?>
The hidden inputs are sent to our email host and based on error or success the host chooses the correct value to send back to.
Currently this doesn't work. I got the php code from here