提交表单(发送包含数据的电子邮件)并重定向到paypal页面

时间:2012-10-30 16:50:54

标签: forms redirect paypal submit

我看到了一些类似的问题,但他们没有得到回答,或者他们并不完全是我正在寻找的。

我的网页上有一个简短的表格。按下“提交”按钮后,表单上的内容将作为电子邮件发送。现在我想添加将用户重定向到paypal页面的功能,他们可以支付管理费。

有没有办法在表单的“提交”按钮中添加一些代码,以便将客户重定向到paypal结账(好像他们按下'立即购买')或者是否有办法定制'但它现在'按钮,也有提交表格的功能?

2 个答案:

答案 0 :(得分:2)

<?php
session_start();
/* Set the variables below */

$contact_us = "contact-form";

$website_url = 'http://www.yourwebsite.com/';
$error_page_url = $website_url . 'error.html';
$paypal_page_url = $website_url . 'paypalpageurl.html';
$dummy_email = 'no-reply@yourwebsite.com';
$receiver_email_id = 'me@yourwebsite.com';

/** WARNING !! Dont make changes below ***/

if(!empty($_REQUEST['uri'])){
    $uri=$_REQUEST['uri'];
}else{
    $uri='';
}


switch($uri){
    case $contact_us:
        contact();
        break;
    default:
        ?><meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $website_url; ?>"><?php

}
function contact($request = "Contact Form"){

    global $error_page_url, $paypal_page_url, $dummy_email, $receiver_email_id,$website_url;

    $subject = "[yourwebsite.com] - Contact Form"; 
    $email = htmlentities($_REQUEST['email']);
    $name = htmlentities($_REQUEST['name']);
    $phone = htmlentities($_REQUEST['phone']);  
    $comment = htmlentities($_REQUEST['comment']);
    $filter = htmlentities($_REQUEST['filter']);
    $headers = "From:" . $dummy_email;
    $headers1 = "From:" . 'no-reply@yourwebsite.com'; 


    $formatted_message = "Request : " . $request . "\n" . "\n" .
                         "Sender Name : " . $name . "(" . $email . ")" . "\n" . "\n" .
                         "Email : " . $email . "\n" . "\n" .    
                         "Phone : " . $phone . "\n" . "\n" .                             
                         "Comment : " . "\n" . $comment . "\n" . "\n";
    $formatted_message_client = "Hi " . $name . ","."\n" . "\n" .
                                "Thanks for contacting us. We will get back to you soon." . "\n" . "\n" .
                                "Regards," . "\n" .
                                "yourwebsite.com Team";

        if($_POST['check'] != $_SESSION['check']) {
                session_destroy();
            ?><meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $error_page_url; ?>"><?php
        }
        else {
            session_destroy();
            if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                ?><meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $error_page_url; ?>"><?php
            }
            else {
        if($name == '' or $email == '' or $phone == '' or $filter != ''){
        ?><meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $error_page_url; ?>"><?php 
    }else{
        if( mail($receiver_email_id, $subject, $formatted_message, $headers1) &&  
            mail($email, $subject, $formatted_message_client, $headers)){
                    //session_destroy();
            ?><meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $paypal_page_url; ?>"><?php
        }else{
            ?><meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $error_page_url; ?>"><?php
        }
    }
    }
}
}
?>

答案 1 :(得分:0)

不,表单提交是通过电子邮件或通过HTTP。

您可以尝试使用JavaScript伪造某些内容,但这必然会以好奇和有趣的方式破解,因此正确的方法是从CGI处理表单提交并返回重定向状态代码。