Search code examples
phppaypalcontact-formpayflowpro

php redirection after execution of contact form code


Friends..!

I want to redirect after some seconds to paypal payflow link as:

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

after entering details in contact form and clicking on send and then showing Email Sent Successfully etc..as

the contact form processer code is as follows :

<?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>";
?>

and the live contact form is at this link : http://www.webngraphicssolutions.com/new_site/html_purple/web-contact-form-order-now/index.php


Solution

  • You can use javascript to redirect the user when the form has been submitted.

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

    Output the above code in your response sent by the form processor.

    Edit: Since the form is ajax based and you want to redirect after 5 seconds, here is the modified answer:

    Put the below code in your ajax success handler.

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