0

我在我的 dayz 服务器上运行 IPN 以自动处理捐款并分发该人购买的任何物品。但是有一个问题......我添加了一个名为“Player 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> 

现在,我看到输入字段被命名为“os0”,所以我尝试mysql_real_escape_string($_POST['os0'])了它并没有返回任何内容。

这是我的 IPN.php:

<?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);  
}  
?> 

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

4

1 回答 1

0

You need to add custom field in your form like

< input type="hidden" name="custom" value="2" >

and to get this field on ipn script use below code

< ?php

if (isset($_REQUEST['custom'])){

$custom = $_REQUEST['custom'];

}

?>

于 2013-09-11T12:32:52.327 回答