使用Paypal按钮+通过电子邮件发送表单 [英] Form with Paypal Button + Email The Entries

查看:205
本文介绍了使用Paypal按钮+通过电子邮件发送表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



基本上,我现在有一个PHP(和JavaScript)PayPal表单,它向我的客户提供了9个下拉式问题。在他们输入这些数据后,他们可以点击一个PayPal按钮,价格会自动显示,数额取决于他们的选择。



然而,由于Paypal有一个描述限制 - 我想知道这个表单是否可以向用户发送PayPal页面,然后向我发送一封包含他们数据条目的电子邮件。

这是为了自定义游戏控制器业务,所以我需要知道他们所有的个性化选择。



数据库看起来太复杂了......因为我会不断地更新选择。 p>

我已将排序位排序,并对PayPal按钮排序。对于变量和价格,使用.csv文件这一切都完全正常。但是,我需要它发送一封电子邮件给我自己。



任何人都可以这样做吗?

如果您需要看到当前的代码,只是让我知道。真的可以做与某人为我做这个。

 <?php 
类控制器{


public $ currency;
public $ shipping;

public $ controllerDir ='';

public $ question_four;
public $ question_five;
public $ question_six;
public $ question_seven;
public $ question_eight;
public $ question_nine;
public $ question_ten;
public $ question_eleven;
public $ question_twelve;

public $ show_question_four = false;
public $ show_question_five = false;
public $ show_question_six = false;
public $ show_question_seven = false;
public $ show_question_eight = false;
public $ show_question_nine = false;
public $ show_question_ten = false;
public $ show_question_eleven = false;
public $ show_question_twelve = false;

public function readCSV($ file_name){

if(file_exists($ file_name)){
$ this-> options ='';
$ file = fopen($ file_name,'r');
while($ row = fgetcsv($ file)){
$ this-> options。='< option value =''。$ row [1]。'>'。 $ row [0]。 < /选项>;


else
$ this-> options ='< option value => - 请回答上述问题 - < / option>';

返回$ this->选项;
}

public function ShowControllerForm(){

?>
< div id =ctrl_wrapper>
< form id =ctrlFormaction =https://www.paypal.com/cgi-bin/webscrmethod =posttarget =_ top>
< table>
< tr>
< th style =text-align:left>
< H1>控制器自定义< / H1>
< / th>
< / tr>
< tr>
< td>
您想定制一个全新的控制器还是自行发送?
< br />
< select name =question_oneid =question_one>
< option value => - 请选择 - < / option>
<?php echo $ this-> readCSV($ this-> controllerDir。'csv / question_one.csv'); ?>
< / select>
< / td>
< / tr>
< tr>
< td>
您想如何为您的控制器添加色彩/设计?
< br />
< select name =question_twoid =question_two>
< option value =selected =selected> - 请选择 - < / option>
<?php echo $ this-> readCSV($ this-> controllerDir。'csv / question_two.csv'); ?>
< / select>
< / td>
< / tr>
< tr>
< td>
您希望控制器拥有哪种设计/颜色?
< br />
< option value =selected =selected> - 请选择 - < / option>
<?php echo $ this-> readCSV($ this-> controllerDir。'csv / question_four.csv'); ?>
< / select>
< / td>
< / tr>
<?php endif; ?>
<?php if($ this-> show_question_five):?>
< tr>
< td>
你希望你的引导按钮有什么样的外观?
< br />
< select name =question_fiveid =question_five>
< option value =selected =selected> - 请选择 - < / option>
<?php echo $ this-> readCSV($ this-> controllerDir。'csv / question_five.csv'); ?>
< / select>
< / td>
< / tr>
<?php endif; ?>
<?php if($ this-> show_question_six):?>
< tr>
< td>
请为指南按钮周围的四个LED选择一种颜色。
< br />
< select name =question_sixid =question_six>
< option value =selected =selected> - 请选择 - < / option>
<?php echo $ this-> readCSV($ this-> controllerDir。'csv / question_six.csv'); ?>
< / select>
< / td>
< / tr>
<?php endif; ?>
<?php if($ this-> show_question_seven):?>>
< tr>
< td>
您希望拇指指甲是什么颜色?
< br />
< select name =question_sevenid =question_seven>
< option value =selected =selected> - 请选择 - < / option>
<?php echo $ this-> readCSV($ this-> controllerDir。'csv / question_seven.csv'); ?>
< / select>
< / td>
< / tr>
<?php endif; ?>
<?php if($ this-> show_question_eight):?>
< tr>
< td>
你想要D-Pad的颜色是什么?
< br />
< select name =question_eightid =question_eight>
< option value =selected =selected> - 请选择 - < / option>
<?php echo $ this-> readCSV($ this-> controllerDir。'csv / question_eight.csv'); ?>
< / select>
< / td>
< / tr>
<?php endif; ?>
<?php if($ this-> show_question_nine):?>
< tr>
< td>
如果有的话,您需要安装哪些MOD包?
< br />
< select name =question_nineid =question_nine>
< option value =selected =selected> - 请选择 - < / option>
<?php echo $ this-> readCSV($ this-> controllerDir。'csv / question_nine.csv'); ?>
< / select>
< / td>
< / tr>
<?php endif; ?>
< tr>
< td>当前控制器价格
< br />
< input type =textreadonly =readonlyid =amountname =amountvalue =0.00><?php echo $ this-> currency; ?>
< / td>
< / tr>
< tr>
< td>
运费< b>仅限英国< / b> (下午1点之前的特别下一天送货)
< br />
< input type =textreadonly =readonlyid =shippingname =shippingvalue =<?php echo $ this-> shipping;?>>< ?php echo $ this-> currency; ?>
< / td>
< / tr>
< tr>
< td>< b>总计< / b> < i>(当前价格+运费)< / i>
< br />
< input type =textreadonly =readonlyid =totalname =totalvalue =0.00><?php echo $ this-> currency; ?>
< / td>
< / tr>
< tr>
< td>
< input type =hiddenname =cmdvalue =_ xclick>
< input type =hiddenname =businessvalue =myemail@somewhere.com>
< input type =hiddenname =lcvalue =UK>
< input type =hiddenid =item_namename =item_namevalue =Controller>
<! - < input type =hiddenid =amountname =amountvalue =0.00> - >
< input type =hiddenname =currency_codevalue =GBP>
< input type =hiddenname =button_subtypevalue =services>
< input type =hiddenname =no_notevalue =0>
<! - < input type =hiddenid =shippingname =shippingvalue =0.00> - >
< input type =hiddenname =bnvalue =PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest>
< input type =hiddenname =os0value =这是一些描述>
< hr size =1/>
< input type =submitid =submitvalue =立即购买! border =0name =submitalt =PayPal - 更安全,更简单的在线支付方式! >
< / td>
< / tr>
< / table>

<! - - < / form>

< p style =padding-top:10px>< / p>
< / div>

< div id =loader>< / div>

< script>
函数ShowMessage(msg){
$(#dialog-message p).text(msg);
$(#dialog-message).dialog({modal:true,width:350,buttons:{OK:function(){$(this).dialog(close);}}}) ;
}
< / script>
< / div>
<?php

}

}

?>

解决方案

您可以将表单提交给PHP脚本,然后PHP脚本将您的订单信息保存到数据库,通过电子邮件发送给您。脚本完成后,您可以简单地使用订单金额重定向到PayPal。一个例子:

 <?php 
if(isset($ _ POST ['submit'])){
//获取用户选项并计算价格
//保存到数据库,通过电子邮件发送订单详细信息,或者(最好是)
//将用户发送到PayPal以支付购买费用
$ query_data = array(
'business'=>'your-paypal-email-address',
'cmd'=>'_xclick',
'item_name'=> ;'Order#'。$ order_id,// $ order_id可以是保存数据库的$ last_insert_id()b $ amount'=>'100.00',//物品的成本
'shipping'= > '10.00'//运送物品的成本
);
header('Location:https://www.paypal.com/cgi-bin/websrc/?'。http_build_query($ query_data));
出口;
}

您需要填充计算价格的位数,保存到数据库和/或通过电子邮件发送订单细节,但应该足以让你去。它主要演示如何在PHP脚本中重定向到PayPal。


I'm new to this site - So I apologise if I've done anything wrong.

Basically, I currently have a PHP (and javascript) Paypal form, which provides 9 drop-down questions to my customers. After they have entered this data, they are then able to click a Paypal button and the price automatically shows with the amount dependant on their choices.

However, as Paypal has a description limit - I was wondering if it's possible for this form to send the user a Paypal page, and then send me an email with their data entry too.

It's for a Custom Gaming Controller business, so I need to know ALL of their personalisation choices.

A database seems too complicated... As I will constantly keep updating the choices.

I have the dropdown bit sorted, and the Paypal button sorted. It all works completely fine using .csv files for the variables and prices. However, I need it to send an email to myself.

Can anyone do this?

If you need to see the current code, just let me know. Could really do with someone doing this for me. Will happily provide a detailed review for your potential clients.

<?php
class Controller {


    public $currency;
    public $shipping;

    public $controllerDir = '';

    public $question_four;
    public $question_five;
    public $question_six;
    public $question_seven;
    public $question_eight;
    public $question_nine;
    public $question_ten;
    public $question_eleven;
    public $question_twelve;

    public $show_question_four   = false;
    public $show_question_five   = false;
    public $show_question_six        = false;
    public $show_question_seven  = false;
    public $show_question_eight  = false;
    public $show_question_nine   = false;
    public $show_question_ten        = false;
    public $show_question_eleven = false;
    public $show_question_twelve = false;

    public function readCSV( $file_name ) {

        if ( file_exists($file_name) ) {
            $this->options = '';
            $file = fopen(  $file_name, 'r' );
            while ($row = fgetcsv($file)) {
                $this->options .= '<option value="' . $row[1] . '">' . $row[0] . '</option>';
            }
        }
        else
            $this->options = '<option value="">- Please answer question above -</option>';

        return $this->options;
    }

    public function ShowControllerForm() {

        ?>
        <div id="ctrl_wrapper">
            <form id="ctrlForm" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
            <table>
                <tr>
                    <th style="text-align: left">
                        <H1>Controller Customization</H1>
                    </th>
                </tr>
                <tr>
                    <td>
                        Would you like to customise a brand new controller or send in your own?
                    <br />
                        <select name="question_one" id="question_one">
                            <option value="">- Please select -</option>
                            <?php echo $this->readCSV( $this->controllerDir . 'csv/question_one.csv' ); ?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        How do you want to add colour/design to your controller?
                    <br />
                        <select name="question_two" id="question_two">
                            <option value="" selected="selected">- Please select -</option>
                            <?php echo $this->readCSV( $this->controllerDir . 'csv/question_two.csv' ); ?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        What design/colour would you like your controller to have?
                            <br />
                        <select name="question_three" id="question_three">
                            <option value="" selected="selected">- Please select -</option>
                        </select>
                    </td>
                </tr>
                <?php if ($this->show_question_four) : ?>
                <tr>
                    <td>
                        What colour would you like the A, B, X and Y buttons?
                            <br />
                        <select name="question_four" id="question_four">
                            <option value="" selected="selected">- Please select -</option>
                            <?php echo $this->readCSV( $this->controllerDir . 'csv/question_four.csv' ); ?>
                        </select>
                    </td>
                </tr>
                <?php endif; ?>
                <?php if ($this->show_question_five) : ?>
                <tr>
                    <td>
                        What appearance do you wish your guide button to have?
                            <br />
                        <select name="question_five" id="question_five">
                            <option value="" selected="selected">- Please select -</option>
                            <?php echo $this->readCSV( $this->controllerDir . 'csv/question_five.csv' ); ?>
                        </select>
                    </td>
                </tr>
                <?php endif; ?>
                <?php if ($this->show_question_six) : ?>
                <tr>
                    <td>
                        Please select a colour for the four LEDs around the guide button.
                            <br />
                        <select name="question_six" id="question_six">
                            <option value="" selected="selected">- Please select -</option>
                            <?php echo $this->readCSV( $this->controllerDir . 'csv/question_six.csv' ); ?>
                        </select>
                    </td>
                </tr>
                <?php endif; ?>
                <?php if ($this->show_question_seven) : ?>
                <tr>
                    <td>
                        What colour do you wish the thumbsticks to be?
                            <br />
                        <select name="question_seven" id="question_seven">
                            <option value="" selected="selected">- Please select -</option>
                            <?php echo $this->readCSV( $this->controllerDir . 'csv/question_seven.csv' ); ?>
                        </select>
                    </td>
                </tr>
                <?php endif; ?>
                <?php if ($this->show_question_eight) : ?>
                <tr>
                    <td>
                        What colour do you want the D-Pad to be?
                            <br />
                        <select name="question_eight" id="question_eight">
                            <option value="" selected="selected">- Please select -</option>
                            <?php echo $this->readCSV( $this->controllerDir . 'csv/question_eight.csv' ); ?>
                        </select>
                    </td>
                </tr>
                <?php endif; ?>
                <?php if ($this->show_question_nine) : ?>
                <tr>
                    <td>
                        If any, what package of MODs would you like installed?
                            <br />
                        <select name="question_nine" id="question_nine">
                            <option value="" selected="selected">- Please select -</option>
                            <?php echo $this->readCSV( $this->controllerDir . 'csv/question_nine.csv' ); ?>
                        </select>
                    </td>
                </tr>
                <?php endif; ?>
                <tr>
                    <td>Current Controller Price
                        <br />
                        <input type="text" readonly="readonly" id="amount" name="amount" value="0.00"><?php echo $this->currency; ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        Shipping <b>UK Only</b> (Special Next-Day Delivery by 1pm)
                    <br />
                        <input type="text" readonly="readonly" id="shipping" name="shipping" value="<?php echo $this->shipping; ?>"><?php echo $this->currency; ?>
                    </td>
                </tr>
                <tr>
                    <td><b>Total</b> <i>(Current Price + Shipping)</i>
                        <br />
                        <input type="text" readonly="readonly" id="total" name="total" value="0.00"><?php echo $this->currency; ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="hidden" name="cmd" value="_xclick">
                        <input type="hidden" name="business" value="myemail@somewhere.com">
                        <input type="hidden" name="lc" value="UK">
                        <input type="hidden" id="item_name" name="item_name" value="Controller">
                        <!--<input type="hidden" id="amount" name="amount" value="0.00">-->
                        <input type="hidden" name="currency_code" value="GBP">
                        <input type="hidden" name="button_subtype" value="services">
                        <input type="hidden" name="no_note" value="0">
                        <!--<input type="hidden" id="shipping" name="shipping" value="0.00">-->
                        <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
                        <input type="hidden" name="os0" value ="here's a bit of a description">
                        <hr size="1"/>
                        <input type="submit" id="submit" value="Purchase Now !" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" >
                    </td>
                </tr>
            </table>

            <!--<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">-->
            </form>

            <div id="dialog-message" title="Please select an option" style="display:none">
                <p style="padding-top:10px"></p>
            </div>

            <div id="loader"></div>

            <script>
                function ShowMessage( msg ) {
                    $( "#dialog-message p" ).text(msg);
                    $( "#dialog-message" ).dialog({modal: true, width: 350, buttons: {OK: function() {$( this ).dialog( "close" );}}});
                }   
            </script>
        </div>
        <?php

    }

}

?>

解决方案

What you could do is have your form submit to a PHP script, and then that PHP script saves your order information to a database, sends to you via email etc. Once the script’s done that, you can simply redirect to PayPal with the order amount. An example:

<?php
if (isset($_POST['submit'])) {
    // get user's options and calculate price
    // either save to database, send order details via email, or (preferably) both
    // send the user to PayPal to pay for purchase
    $query_data = array(
        'business' => 'your-paypal-email-address',
        'cmd' => '_xclick',
        'item_name' => 'Order #' . $order_id, // $order_id could be last_insert_id() from saving database
        'amount' => '100.00', // the cost of the item
        'shipping' => '10.00' // the cost of shipping the item
    );
    header('Location: https://www.paypal.com/cgi-bin/websrc/?' . http_build_query($query_data));
    exit;
}

You’ll need to flesh out the bits where you calculate the price, and saving to the database and/or sending the order details via email, but should be enough to get you going. It’s mainly to demonstrate how to redirect to PayPal in your PHP script.

这篇关于使用Paypal按钮+通过电子邮件发送表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆