我正在开发一种小型表格,用户可以在其中使用PayPal付款进行注册。 但是问题是,成功付款后,用户信息未存储在数据库中。 这是插入代码
$db = new mysqli($dbConfig['host'], $dbConfig['username'], $dbConfig['password'], $dbConfig['name']);
// Assign posted variables to local data array.
$data = [
'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'],
'payer_email' => $_POST['payer_email'],
'custom' => $_POST['custom'],
];
if(verifyTransaction($_POST) && checkTxnid($data['txn_id'])) {
if(addPayment($data) !== FALSE) {
}
}
function addPayment($data)
{
global $db;
if(is_array($data)) {
$stmt = $db->prepare('INSERT INTO `payments` (txnid, payment_amount, payment_status, itemid, payer_email) VALUES( ?, ?, ?, ?, ?)');
$stmt->bind_param(
'sdsss',
$data['txn_id'],
$data['payment_amount'],
$data['payment_status'],
$data['item_number'],
$data['payer_email']
);
$stmt->execute();
$stmt->close();
return $db->insert_id;
}
return FALSE;
}
答案 0 :(得分:0)
从付款INSERT INTO payments
中删除单引号,然后在上面的表值中将此itemid更改为item_number。