0

我是这个网站的新手——所以如果我做错了什么,我深表歉意。

基本上,我目前有一个 PHP(和 javascript)Paypal 表单,它为我的客户提供了 9 个下拉问题。输入此数据后,他们可以单击 Paypal 按钮,价格会自动显示,金额取决于他们的选择。

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

这是针对自定义游戏控制器业务的,因此我需要了解他们所有的个性化选择。

数据库似乎太复杂了......因为我会不断更新选择。

我对下拉位进行了排序,并对 Paypal 按钮进行了排序。使用 .csv 文件作为变量和价格,这一切都很好。但是,我需要它向自己发送电子邮件。

谁能做到这一点?

如果您需要查看当前代码,请告诉我。真的可以和为我做这件事的人一起做。很乐意为您的潜在客户提供详细的评论。

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

    }

}

?>

4

1 回答 1

0

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

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

您需要充实计算价格的部分,并保存到数据库和/或通过电子邮件发送订单详细信息,但应该足以让您继续前进。它主要是为了演示如何在您的 PHP 脚本中重定向到 PayPal。

于 2013-09-05T20:46:56.453 回答