我想知道如何制作表格&#34;提交&#34;也是echo("<a href='.signalservice/subscription.php?customer_id=" . $result->customer->id . "'>Create subscription for this customer</a>");
我的代码是:
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/>");
}
}
?>
答案 0 :(得分:0)
如果您想同时使用,请提交表单并重定向我建议使用jQuery。在您的链接中添加ID,并阻止使用preventDefault()
进行默认操作。然后,您可以使用AJAX请求提交表单,并在表单发布后,您可以重定向到链接src
。试试这个:
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>