I would like to know how to make form "submit" also a echo("<a href='.signalservice/subscription.php?customer_id=" . $result->customer->id . "'>Create subscription for this customer</a>");
My code is :
if ($result->success) {
echo '
<form action="//tradeitsimple.us3.list-manage.com/subscribe/post?u=fc50a4fa89bccc3ad26bb4c71&id=b9d9e2fe10" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<label for="mce-EMAIL">You will receive signals through email, please leave your email address!</label>
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
';
echo("Success! Customer ID: " . $result->customer->id . "<br/>");
echo("<a href='.signalservice/subscription.php?customer_id=" . $result->customer->id . "'>Create subscription for this customer</a>");
} else {
echo("Validation errors:<br/>");
foreach (($result->errors->deepAll()) as $error) {
echo("- " . $error->message . "<br/>");
}
}
?>
If you want to to both, submit the form and redirect i recommand to use jQuery. Add an id to your link and prevent the default action with preventDefault()
. Then you can submit the form with an AJAX request and after the form is posted you can redirect to the link's src
. Try this:
if ($result->success) {
echo '
<form action="//tradeitsimple.us3.list-manage.com/subscribe/post?u=fc50a4fa89bccc3ad26bb4c71&id=b9d9e2fe10" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<label for="mce-EMAIL">You will receive signals through email, please leave your email address!</label>
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
';
echo("Success! Customer ID: " . $result->customer->id . "<br/>");
echo("<a id=\"myLinkId\" href='.signalservice/subscription.php?customer_id=" . $result->customer->id . "'>Create subscription for this customer</a>");
} else {
echo("Validation errors:<br/>");
foreach (($result->errors->deepAll()) as $error) {
echo("- " . $error->message . "<br/>");
}
}
?>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
$(document).on('click','#myLinkId',function(e)
{
e.preventDefault();
var link = $(this);
var form = $('#mc-embedded-subscribe-form');
var dataArray = form.serializeArray();
$.post(form.attr('action'), dataArray, function(){
window.location.href=link.attr('src');
});
});
</script>
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.