那麼對於我的網站,我希望我的用戶成爲每月會員。所以一旦他們購買了會員資格,他們將擁有31天的會員資格。我如何做到這一點,當31天用完時,他們失去了會員資格。我也想讓每月的會員資格反覆出現。我想生病只是告訴你們我的ipn paypal。如何編碼定時會員?
<?php
include("session1.php");
ini_set('log_errors', true);
ini_set('error_log', dirname(__FILE__).'/ipn_errors.log');
include('ipnlistener.php');
$listener = new IpnListener();
$listener->use_sandbox = true;
try {
$listener->requirePostMethod();
$verified = $listener->processIpn();
} catch (Exception $e) {
error_log($e->getMessage());
exit(0);
}
if ($verified) {
$errmsg = '';
if ($_POST['payment_status'] != 'Completed') {
exit(0);
}
if ($_POST['mc_currency'] != 'USD') {
$errmsg .= "'mc_currency' does not match: ";
$errmsg .= $_POST['mc_currency']."\n";
}
else
require("include/config.php");
$mailer = "[email protected]";
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$email = $_POST['payer_email'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$custom = $_POST["custom"];
$userid = $custom;
mysql_query("UPDATE users SET plan='$item_name', memberstatus='member', subdays='31' WHERE username='$userid'");
$sql = "INSERT INTO orders VALUES
(NULL, '$userid', '$receiver_email', '$item_name', '$payment_amount')";
echo "Payment accpeted. Redirecting ";
if (!mysql_query($sql)) {
error_log(mysql_error());
exit(0);
}
}
?>
而且,請不要使用新代碼'mysql_ *'功能。他們不再被維護,社區已經開始[棄用流程](http://goo.gl/KJveJ)。查看[**紅框**](http://php.net/manual/en/function.mysql-pconnect.php)?相反,您應該瞭解[準備好的語句](http://goo.gl/vn8zQ)並使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli的)。如果你不能決定,[本文](http://goo.gl/3gqF9)將有助於選擇。如果你關心學習,[這是一本很好的PDO教程](http://goo.gl/vFWnC)。 –