从PHP表单传递值到Paypal金额

时间:2014-09-05 18:10:42

标签: php html paypal

我有一个表单来选择一个值,然后我想要paypal按钮上的值。我似乎无法传递价值。我究竟做错了什么?这是形式:

<form method="post">
        <select id="select" name="valor">
            <option value="" selected="selected">...</option>
            <option value="5"> 5</option>
            <option value="10"> 10</option>
            <option value="15"> 15</option>
            <option value="20"> 20</option>
            <option value="25"> 25</option>
            <option value="30"> 30</option>
            <option value="35"> 35</option>
            <option value="40"> 40</option>
            <option value="45"> 45</option>
            <option value="50"> 50</option>
            <option value="55"> 55</option>
            <option value="60"> 60</option>
            <option value="65"> 65</option>
            <option value="70"> 70</option>
            <option value="75"> 75</option>
            <option value="80"> 80</option>
            <option value="85"> 85</option>
            <option value="90"> 90</option>
            <option value="95"> 95</option>
            <option value="100"> 100</option>
            <option value="105"> 105</option>
            <option value="110"> 110</option>
            <option value="115"> 115</option>
            <option value="120"> 120</option>
            <option value="125"> 125</option>
        </select>
    </form>

我想传递给金额的paypal按钮。这是代码:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">                 
    <table width="90%" align='center' border=0>
        <tr>
            <td width='130px'>
                <img src="<?=$SETTINGS['siteurl']?>themes/<?=$SETTINGS['theme']?>/img/paypal_small_logo.gif" alt='' width="124" height="39" style="vertical-align:middle;"/>
                <input type="hidden" name="custom" value='<?= $_SESSION['payment_type'] ?>==<?=$_SESSION['auction_id'] ?>==<?=$_SESSION['TPL_id_hidden'] ?>==<?=$_SESSION['pre_registration'] ?>'>
                <input type="hidden" name="cmd" value="_xclick">
                <input type="hidden" name="business" value="<?=$SETTINGS['admin_paypal']?>">
                <input type="hidden" name="item_name" value="Auction Bid">
                <input type="hidden" name="item_number" value="001">
                <input type="hidden" name="amount" value="<? echo $_POST['valor']?>">
                <input type="hidden" name="no_shipping" value="0">
                <input type="hidden" name="no_note" value="1">
                <input type='hidden' name='return' value='<?=$SETTINGS['siteurl']?>payment_history.php'>
                <input type='hidden' name='cancel_return' value='<?=$SETTINGS['siteurl']?>yourbalance.php'>
                <input type='hidden' name='notify_url' value='<?=$SETTINGS['siteurl']?>payment_processing.php'>
                <input type="hidden" name="currency_code" value="<?=$SETTINGS['currency']?>">
                <input type="hidden" name="lc" value="EN">
                <input type="hidden" name="bn" value="PP-BuyNowBF">                         
              </td>
            <td>
                <input class="button"  type="submit" value="Pay with Paypal" name="submit"  alt="PayPal">                           
           </td>
       </tr>
    </table>
</form>       

2 个答案:

答案 0 :(得分:2)

除非您将valor select放在名为amount的paypal表单中,否则您需要提交第一个表单,以便PHP可以在响应中应用这些值。

您可以执行以下操作以避免提交第一个表单:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">                 
    <table width="90%" align='center' border=0>
        <tr>
            <td width='130px'>
                <img src="<?=$SETTINGS['siteurl']?>themes/<?=$SETTINGS['theme']?>/img/paypal_small_logo.gif" alt='' width="124" height="39" style="vertical-align:middle;"/>
                <input type="hidden" name="custom" value='<?= $_SESSION['payment_type'] ?>==<?=$_SESSION['auction_id'] ?>==<?=$_SESSION['TPL_id_hidden'] ?>==<?=$_SESSION['pre_registration'] ?>'>
                <input type="hidden" name="cmd" value="_xclick">
                <input type="hidden" name="business" value="<?=$SETTINGS['admin_paypal']?>">
                <input type="hidden" name="item_name" value="Auction Bid">
                <input type="hidden" name="item_number" value="001">
                <input type="hidden" name="no_shipping" value="0">
                <input type="hidden" name="no_note" value="1">
                <input type='hidden' name='return' value='<?=$SETTINGS['siteurl']?>payment_history.php'>
                <input type='hidden' name='cancel_return' value='<?=$SETTINGS['siteurl']?>yourbalance.php'>
                <input type='hidden' name='notify_url' value='<?=$SETTINGS['siteurl']?>payment_processing.php'>
                <input type="hidden" name="currency_code" value="<?=$SETTINGS['currency']?>">
                <input type="hidden" name="lc" value="EN">
                <input type="hidden" name="bn" value="PP-BuyNowBF">

                <select id="select" name="amount">
                    <option value="" selected="selected">...</option>
                    <option value="5"> 5</option>
                    <option value="10"> 10</option>
                    <option value="15"> 15</option>
                    <option value="20"> 20</option>
                    <option value="25"> 25</option>
                    <option value="30"> 30</option>
                    <option value="35"> 35</option>
                    <option value="40"> 40</option>
                    <option value="45"> 45</option>
                    <option value="50"> 50</option>
                    <option value="55"> 55</option>
                    <option value="60"> 60</option>
                    <option value="65"> 65</option>
                    <option value="70"> 70</option>
                    <option value="75"> 75</option>
                    <option value="80"> 80</option>
                    <option value="85"> 85</option>
                    <option value="90"> 90</option>
                    <option value="95"> 95</option>
                    <option value="100"> 100</option>
                    <option value="105"> 105</option>
                    <option value="110"> 110</option>
                    <option value="115"> 115</option>
                    <option value="120"> 120</option>
                    <option value="125"> 125</option>
                </select>    

              </td>
            <td>
                <input class="button"  type="submit" value="Pay with Paypal" name="submit"  alt="PayPal">                           
           </td>
       </tr>
    </table>
</form> 

答案 1 :(得分:0)

也许这就是原因:

<option value="[you forgot the value for the first option LOL]" selected="selected">...</option>

我看不到任何其他问题。