Php 如何提取自定义字段';我的IPN脚本中的值是多少?

Php 如何提取自定义字段';我的IPN脚本中的值是多少?,php,paypal,paypal-ipn,Php,Paypal,Paypal Ipn,我在我的dayz服务器上运行IPN,自动处理捐款并分发此人购买的任何商品。但有一个问题……我添加了一个名为“玩家ID”的自定义字段,要求他们填写,因为它稍后会在数据库条目中使用。我的shopping.php页面如下所示: <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick">

我在我的dayz服务器上运行IPN,自动处理捐款并分发此人购买的任何商品。但有一个问题……我添加了一个名为“玩家ID”的自定义字段,要求他们填写,因为它稍后会在数据库条目中使用。我的shopping.php页面如下所示:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">  
    <input type="hidden" name="cmd" value="_xclick">  
    <input type="hidden" name="business" value="myemail@gmail.com">  
    <input type="hidden" name="item_name" value="Alice Pack">  
    <input type="hidden" name="item_number" value="300">  
    <input type="hidden" name="amount" value="0.10">  
    <input type="hidden" name="no_shipping" value="0">  
    <input type="hidden" name="no_note" value="1">  
    <input type="hidden" name="currency_code" value="CAD">  
    <input type="hidden" name="lc" value="AU">  
    <input type="hidden" name="bn" value="PP-BuyNowBF">  
    <table>
<tr><td><input type="hidden" name="on0" value="Player Unique ID">Player Unique ID</td></tr><tr><td><input type="text" name="os0" maxlength="200"></td></tr>
</table>
    <input type="image" src="https://www.paypal.com/en_AU/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">  
    <img alt="" border="0" src="https://www.paypal.com/en_AU/i/scr/pixel.gif" width="1" height="1">  
</form> 

有没有办法让我所需的帖子在我的IPN中工作?

您需要在表单中添加自定义字段,如

要在ipn脚本上获取此字段,请使用以下代码

<?php

如果(isset($_请求['custom'])){

$custom=$_请求['custom']

}


?>

PSA:mysql的函数是。不建议编写新代码,因为这样会阻止您将来升级。你不能提交任何你喜欢的旧字段,你必须使用贝宝期望的字段。此外,您真的应该在本地存储此值,并且只向payupalCould发送一个事务id。我是否可以将唯一id存储为会话,然后在IPN.php中调用该会话?否,因为human\browser不会命中IPN脚本。因此,我如何存储该变量并使其在我的IPN脚本中运行?
<?php  

mysql_connect("dbhost", "dbuser", "dbpass") or die(mysql_error());  
mysql_select_db("db") or die(mysql_error());  

// read the post from PayPal system and add 'cmd'  
$req = 'cmd=_notify-validate';  
foreach ($_POST as $key => $value) {  
$value = urlencode(stripslashes($value));  
$req .= "&$key=$value";  
}  
// post back to PayPal system to validate  
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";  
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";  
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";  

$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);  
if (!$fp) {  
// HTTP ERROR  
} else {  
fputs ($fp, $header . $req);  
while (!feof($fp)) {  
$res = fgets ($fp, 1024);  
if (strcmp ($res, "VERIFIED") == 0) {  
    $id = mysql_real_escape_string($_POST['item_number']);
    $uniqueid = mysql_real_escape_string($_POST['os0']);
// PAYMENT VALIDATED & VERIFIED!  
mysql_query("INSERT INTO cust_loadout_profile (cust_loadout_id, unique_id) VALUES ('$id', '$uniqueid')");
$to      = 'myemail@gmail.com';  
$subject = 'Download Area | Login Credentials';  
$message = ' 

Thank you for your purchase 

Your account information 
------------------------- 
Email: '.$id.' 
Password: '.$password.' 
------------------------- 
             SUCCESS
You can now login at http://yourdomain.com/PayPal/';  
$headers = 'From:noreply@yourdomain.com' . "\r\n";  

mail($to, $subject, $message, $headers);  
}  

else if (strcmp ($res, "INVALID") == 0) {  

// PAYMENT INVALID & INVESTIGATE MANUALY!  
  $to      = 'myemail@gmail.com';  
$subject = 'Download Area | Login Credentials';  
$message = ' 

Thank you for your purchase 
 THIS IS ALSO AN ERROR
Your account information 
------------------------- 
Email: '.$email.' 
Password: '.$password.' 
------------------------- 

You can now login at http://yourdomain.com/PayPal/';  
$headers = 'From:noreply@yourdomain.com' . "\r\n";  

mail($to, $subject, $message, $headers);  
}  
}  
fclose ($fp);  
}  
?>