执行联系表单代码后的PHP重定向

时间:2013-10-19 09:11:01

标签: php paypal contact-form payflowpro

友..!

我想在几秒钟之后重定向到paypal payflow链接:

  

https://pilot-payflowlink.paypal.com/?MODE=TEST&SECURETOKENID=f976bec739fb40a5a0e48c1876d570e6&SECURETOKEN=7yVdfkdwbgkOzAg2h1vxHggvL

在联系表单中输入详细信息并单击“发送”,然后显示“已成功发送电子邮件”等等。

联系表格处理程序代码如下:

<?php
$cardlink = $_POST['cardlink'];
$howmuch = $_POST['howmuch'];
$name = $_POST['name'];
$email = $_POST['email'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$website = $_POST['website'];
$comments = $_POST['comments'];
$formcontent="Card Image Link: $cardlink \n How much cards: $howmuch \n From: $name \n Email: $email \n Address: $address \n Phone: $phone \n Website: $website \n Additinal Informations: $comments";
$recipient = "nicefellow1234@gmail.com";
$subject = "Card Designig Order By : $name ";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
// Email has sent successfully, echo a success page.
 echo "<fieldset>";
 echo "<div id='success_page'>";
 echo "<h1>Email Sent Successfully.</h1>";
 echo "<p>Thank you <strong>$name</strong>, your message has been submitted to us.</p>";
 echo "</div>";
 echo "</fieldset>";
?>

,实时联系表单位于以下链接:http://www.webngraphicssolutions.com/new_site/html_purple/web-contact-form-order-now/index.php

2 个答案:

答案 0 :(得分:0)

您可以在提交表单时使用javascript重定向用户。

<script type="text/javascript">
  window.onload = function () {
    window.location.href = "https://pilot-payflowlink.paypal.com/?MODE=TEST&SECURETOKENID=f976bec739fb40a5a0e48c1876d570e6&SECURETOKEN=7yVdfkdwbgkOzAg2h1vxHggvL";
  };
</script>

在表单处理器发送的响应中输出上述代码。

修改 由于表单是基于ajax的,并且您想在5秒后重定向,这里是修改后的答案:

将以下代码放入ajax成功处理程序中。

window.setTimeout(function () {
  window.location.href = "https://pilot-payflowlink.paypal.com/?MODE=TEST&SECURETOKENID=f976bec739fb40a5a0e48c1876d570e6&SECURETOKEN=7yVdfkdwbgkOzAg2h1vxHggvL";
}, 5000);

答案 1 :(得分:-1)

使用setInterval函数

setInterval(function(){
    // Do something every 2 seconds
}, 2000);