【发布时间】:2011-09-29 06:54:48
【问题描述】:
向我们的支付网关提交支付表单(信用卡等)后,我们会在支付被批准时收到“response_code”1。然后,我们使用以下代码更新数据库中的用户信息以反映已批准的交易。
但是,大约每 10 次,即使交易返回了批准的响应,用户的信息也不会更新。这段代码有什么明显错误吗?或者可能由于某种原因 response_code 不等于 1?
<?php
session_start();
if ($_GET['response_code'] == 1)
{
require('scripts/global.php'); //connect to database
$email = $_SESSION['email'];
$level = 3;
$transaction_id = "" . htmlentities($_GET['transaction_id']);
mysql_query ("UPDATE `users` SET level = '$level', trans_id = '$transaction_id' WHERE `email` = '$email'"); //update user info
$error = "false";
}
else
{
$noerror = "true";
$message = "Sorry, an error occurred: " . htmlentities($_GET['response_reason_text']);
}
?>
【问题讨论】:
-
是什么阻止我设置
?response_code=1?此外,您可能会受到 SQL 注入攻击!
标签: php mysql session payment-gateway