我建立了一个网站,客户可以在其中输入他们的信息(姓名、地址等),并希望他们能够通过贝宝使用信用卡付款。效果很好。我已经设置了 Paypal 即时付款通知,并通过 paypal 设置客户被重定向到我的页面。除了数据没有被传递并保存到我的 SQL 数据库之外,这一切都正常工作。我知道将数据插入数据库的代码可以正常工作。问题是数据没有被传递到该页面,因为贝宝页面介于两者之间。
这是我的php
if (isset($_POST['child_name'])
&& isset($_POST['age'])
&& isset($_POST['hometown'])
&& isset($_POST['boy_girl'])
&& isset($_POST['email'])
&& isset($_POST['first_name'])
&& isset($_POST['last_name'])
&& isset($_POST['address1'])
&& isset($_POST['address2'])
&& isset($_POST['city'])
&& isset($_POST['state'])
&& isset($_POST['zip'])
&& isset($_POST['country'])) {
$child_name = $_POST['child_name'];
$age = $_POST['age'];
$hometown = $_POST['hometown'];
$boy_girl = $_POST['boy_girl'];
$email = $_POST['email'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$country = $_POST['country'];
}
这是HTML
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="NT2YC6LP7SWBE">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<input type="hidden" name="child_name" id="child_name" value ="<? echo $child_name; ?>" maxlength="20"/>
<input type="hidden" name="age" id="age" value ="<? echo $age; ?>" maxlength="4"/>
<input type="hidden" name="hometown" id="hometown" value ="<? echo $hometown; ?>" maxlength="32"/>
<input type="hidden" name="boy_girl" id="boy_girl" value ="<? echo $boy_girl; ?>" maxlength="4"/>
<input type="hidden" name="first_name" id="first_name" value ="<? echo $first_name; ?>" maxlength="32"/>
<input type="hidden" name="last_name" id="last_name" value ="<? echo $last_name; ?>" maxlength="32"/>
<input type="hidden" name="email" id="email" value ="<? echo $email; ?>" maxlength="64"/>
<input type="hidden" name="address1" id="address1" value ="<? echo $address1; ?>" maxlength="64"/>
<input type="hidden" name="address2" id="address2" value ="<? echo $address2; ?>" maxlength="32"/>
<input type="hidden" name="city" id="city" value ="<? echo $city; ?>" maxlength="32"/>
<input type="hidden" name="state" id="state" value ="<? echo $state; ?>" maxlength="20"/>
<input type="hidden" name="zip" id="zip" value ="<? echo $zip; ?>" maxlength="10"/>
<input type="hidden" name="country" id="country" value ="<? echo $country; ?>" maxlength="32"/>
<input type="hidden" name="payment_type" id="payment_type" value ="paypal" maxlength="6"/>
<input type="hidden" name="paid" id="paid" value ="yes" maxlength="3"/>
<input type="hidden" name="mailed" id="mailed" value ="no" maxlength="3"/>
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
我只是采用了贝宝给我的表格并添加了隐藏的输入。这在另一个页面上完美运行,但这是因为 action 属性直接指向将插入数据的页面。在这里,操作将它们发送到贝宝的网站,而数据永远不会进入我的网站。我该如何调整?