所以这就是问题,我正在尝试做PDT并获取基本信息并发布到sql,更重要的是自定义变量。它是一个整数,在“user_level”和“approved”下用户称为“lvel”也是“apv”,但如果我手动将其设置为“1,2,3..etc”,它会放置该值,但如果我使用$ apv或$ lvel ..它不会插入..任何想法?太棒了警告..试验中非常混乱..
<?php
session_start();
$sid = session_id();
include 'dbc.php';
?>
<?php
$pp_hostname = "www.sandbox.paypal.com"; // Change to www.sandbox.paypal.com to test against sandbox
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
$tx_token = $_GET['tx'];
$auth_token = "_nothing to see here_";
$req .= "&tx=$tx_token&at=$auth_token";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://$pp_hostname/cgi-bin/webscr");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
//set cacert.pem verisign certificate path in curl using 'CURLOPT_CAINFO' field here,
//if your server does not bundled with default verisign certificates.
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $pp_hostname"));
$res = curl_exec($ch);
curl_close($ch);
if(!$res){
//HTTP ERROR
}else{
// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['payment_gross'];
echo ("<p><h3>Thank you for your purchase!</h3></p>");
echo ("<b>Payment Details</b><br>\n");
echo ("<li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $itemname</li>\n");
echo ("<li>Amount: $amount</li>\n");
//echo ('$sid');
}
}echo("$amount");
$apv = '1';
if($amount == "4.00"){
$level = '1';
$sub =1;
}
if($amount == "6.00"){
$lvel = '2';
$sub =1;
}
if($amount == "10.00"){
$lvel = '3';
$sub =1;
}
if($amount == "14.00"){
$lvel = '4';
$sub =1;
}
if($amount == "20.00"){
$lvel = '5';
$sub =1;
}
if($amount == "25.00"){
$lvel = '6';
$sub =1;
}
if($amount == "30.00"){
$lvel = '7';
$sub =1;
}
if($amount == "40.00"){
$lvel = '8';
$sub =1;
}
if($amount == "12.00"){
$level = '1';
$sub =2;
}
if($amount == "22.00"){
$lvel = '2';
$sub =2;
}
if($amount == "32.00"){
$lvel = '3';
$sub =2;
}
if($amount == "42.00"){
$lvel = '4';
$sub =2;
}
if($amount == "66.00"){
$lvel = '5';
$sub =2;
}
if($amount == "80.00"){
$lvel = '6';
$sub =2;
}
if($amount == "95.00"){
$lvel = '7';
$sub =2;
}
if($amount == "125.00"){
$lvel = '8';
$sub =2;
}
mysql_query("update users set approved='$apv' where sid='$sid'");
mysql_query("update users set user_level='$lvel' where sid='$sid'");
//else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation
// }
?>
<?php
$apv1 = '1';
mysql_query("update users set approved='$apv1' where sid='$sid'");
?>
Your transaction has been completed, and a receipt for your purchase has been emailed to you.<br> You may log into your account at <a href='https://www.paypal.com'>www.paypal.com</a> to view details of this transaction.<br>