【发布时间】:2015-05-17 13:14:15
【问题描述】:
notify_url.php
<?php
include('connection.php');
$sql = "UPDATE tablename
SET credit = credit + {$_POST['amount']}
WHERE username = '123456789'";
mysqli_query($con, $sql);
?>
表单 html
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="6RNT8A4HBBJRE">
<input type="image"
src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif"
border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif"
width="1" height="1">
<input name="amount" value=10.95 type="hidden"> <<< not sure if this line should be here
<input name="notify_url" value="notify_url.php" type="hidden">
</form>
上面的代码是我的 notify_url.php 文件中的代码。我的数据库没有被更新:(。我的连接文件没问题。当我输入一个数字而不是 POST 变量时,它工作正常。这只意味着我的 POST 变量可能是错误的,或者根本没有调用脚本!
编辑: 第二个代码是从 PayPal 网站生成的表单(购买按钮)。
【问题讨论】: