所以出于某种原因,这个脚本不会用我在“ if (strcmp ($res, "VERIFIED") == 0) { " 块中告诉它的内容来更新我的 MySQL 数据库。然而, file_put_contents('log.txt', 'verif'); 那是在那个街区,工作得很好。
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
if($_POST) {
$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) {
file_put_contents('log.txt', 'httperrrrr');
die();
} else {
file_put_contents('log.txt', 'die here');
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (stripos($res, "VERIFIED") !== false)
if ($_POST['payment_status'] = "Completed") {
$con = mysqli_connect("****","****","****","****");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$username = $_POST['custom'];
$date = date('Y-m-d');
mysqli_query($con, "UPDATE users SET access='user', invoice_paid='$date' WHERE username='$username'");
mysqli_close($con);
file_put_contents('log.txt', 'verified');
}
} else if (stripos($res, "INVALID") !== false)
file_put_contents('log.txt', $_POST['payment_status']);
}
}
}
}
?>