这就是我所做的,以防其他人想知道。第一个表单提交给这个 php 脚本,其中包含一个新表单并使用旧表单中的数据来填写金额部分。然后如果表单发送成功,第二个是用 JS 提交的。
毫不拖延地,您可以发送多个这样的表单,尽管从技术上讲不是从一页开始,它会以这种方式呈现给用户。
<script type="text/javascript">
function submitt()
{
setTimeout('document.paypal.submit()',1000);
}
</script>
<?php
$Amount = $_REQUEST['amount'];
$to = "XXXX";
$from = $_REQUEST['email'];
$name = $_REQUEST['Name'];
$headers = "From: $from" . PHP_EOL;
$subject = "Classified Ad submission";
$fields = array();
$fields["Name"] = "\nName";
$fields["email"] = "\nEmail";
$fields["Phone"] = "\nPhone";
$fields["WorkPhone"] = "\nWork Phone";
$fields["Address"] = "\nStreet Address";
$fields["City"] = "City";
$fields["State"] = "State";
$fields["Zip"] = "Zip Code";
$fields["Classification"] = "\nClassification";
$fields["Ad-Headline"] = "\nHeadline";
$fields["Other-Classification"] = "\nAlternate Classification";
$fields["Ad-Content"] = "\nAd Content";
$fields["Words"] = "\nWord Count";
$fields["Weeks"] = "\nWeeks to Run";
$fields["WordCount"] = "\nTotal Words";
$fields["Rate"] = "\nWord Rate";
$fields["GrossAmountDue"] = "\nGross Amount";
$fields["NonProfit"] = "\nNon Profit Ad?";
$body = "This Ad has been submitted:\n\n";
foreach ($fields as $a => $b) {
$body .= sprintf("%20s: %s\n", $b, $_REQUEST[$a]);
}
if ($from == '') {
print "You have not entered an email, please go back and try again";
} else {
if ($name == '') {
print "You have not entered a name, please go back and try again";
} else {
$send = mail($to, $subject, $body, "From: XXXX" . PHP_EOL);
if ($send) {
print "Thank you $Name, your Ad has been submitted, redirecting to paypal.";
echo "<SCRIPT LANGUAGE='javascript'>submitt();</SCRIPT>";
} else {
print "ERROR";
}
}
}
?>
<form action="https://www.paypal.com/cgi-bin/webscr" id="paypal" onClick="sendtotal()" target="_top" name="paypal" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="XXXXXXXXXXX">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Classified Ad">
<input type="hidden" name="amount" value="<?php echo $_POST['amount'];?>" />
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller:">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="shipping" value="0.00">
</form>