php
2012-05-05 82 views 0 likes 
0

我有一个变量的数组,我传递给贝宝通过。我遇到的问题是,当贝宝屏幕加载项目,数量,价格部分是空的。下面是合格的代码片段: - (阵列cart_stock和cart_price保持数据传递,$ tmp_cart_count持有的总项目数传)php传递数组到PayPal

<?php 
echo "<form target='PayPal' action='https://www.sandbox.paypal.com/cgi-bin/webscr' method='post'>"; 
echo "<input name='cmd' value='_xclick' type='hidden' />"; 
echo "<input name='upload' value='1' type='hidden' />"; 
echo "<input name='business' value='[email protected]' type='hidden' />"; 

// other irrelevant variables are passed here // 

$i=0;$count=1; 
while ($i < $tmp_cart_count) 
    { 
    echo "<input name='custom' value='".$_SESSION['cart_stock'][$i]."' type='hidden' >"; 
    echo "<input name='item_name_".($count)."' value='".$_SESSION['cart_title'][$i]."' type='hidden' >"; 
    echo "<input name='quantity_".($count)."' value='1' type='hidden' >";    
    echo "<input name='amount_".($count)."' value='".$_SESSION['cart_price'][$i]."' type='hidden' >"; 
    echo "<input name='shipping_".($count)."' value='0' type='hidden' >"; 
    $i++; 
    $count++; 
    } 
echo "<input type='submit' value='PayPal'>"; 
echo "</form>"; 
?> 

任何帮助将不胜感激,因为它有我难倒。

+0

'$ _SESSION ['cart_price'] [$ i]'包含任何东西吗? –

+0

尝试修改'

'标签的'action'属性以将数据发送到服务器上的某个脚本。在这个脚本中,转储所有的发布数据,比如'var_dump($ _ POST);'来查看是否通过表单发送了正确的数据。 –

+0

变量是活的。数组的print_r显示它已填充。我在while循环里面也有下面的代码.//// err chk echo“item_name _”。($ count)。“is:”。$ _ SESSION ['cart_title'] [$ i]。“
”; echo“quantity _”。($ count)。“is:1
”; echo“amount _”。($ count)。“is:”。$ _ SESSION ['cart_price'] [$ i]。“
”; –

回答

2

尝试改变

echo "<input name='cmd' value='_xclick' type='hidden' />"; 

echo "<input name='cmd' value='_cart' type='hidden' />"; 

我认为,可能的帮助。

相关问题