提前谢谢!
的index.php
<?
$products = $mysqli->query("SELECT * FROM `product` WHERE `id` > '0' ORDER BY `price` ASC");
for($j=1; $product = $products->fetch_assoc(); $j++){
?>
<?
if(isset($_POST['submit'])){
redirect_to('functions/paypal/paypal.php');
}
?>
<form method="post">
<tr style="border-bottom:1px solid #f2f3f6;">
<td><?=$product['name'];?></td>
<td><?=$product['price'];?></td>
<td><input type="submit" value="Buy" name="submit" /></td>
</tr>
</form>
<?}?>
&#13;
paypal.php表格
<?
require('functions/db.php');
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>redirect to paypal service..</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<script type="text/javascript">
setTimeout('document.formpaypal.submit()',1000);
</script>
</head>
<body>
<form name="formpaypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?=$sites['paypal']?>">
<input type="hidden" name="item_name" value="<?=$product['name'];?>">
<input type="hidden" name="custom" value="<?=$data['id'];?>">
<input type="hidden" name="amount" value="<?=$product['price'];?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="rm" value="1">
<input type="hidden" name="return" value="index.php?success">
<input type="hidden" name="cancel_return" value="index.php?cancel">
<input type="hidden" name="notify_url" value="funtions/paypal/ipn.php">
</form>
</body>
</html>
&#13;
答案 0 :(得分:0)
你在paypal.php中所做的事情应该只在index.php中完成。您可以直接在索引中构建付款表单,当他们从那里点击提交时,它会将它们直接发送到PayPal。不需要“中间人”剧本。