Removed bug that allows duplicate entries per donation in the thankyou_a_b table Signed-off-by: Edouard Poitras <edouard@eclipse.org>
diff --git a/thankyou.php b/thankyou.php index cf57554..a8e6157 100644 --- a/thankyou.php +++ b/thankyou.php
@@ -76,8 +76,11 @@ $data = $paypal->get_transaction_data(); $amount = $app->sqlSanitize($data['amount']); $test = $app->sqlSanitize($_GET['cm']); - if (is_numeric($amount)) { - $sql = "INSERT INTO thankyou_a_b VALUES (NOW(), '$test', $amount)"; + $transaction_id = $data['transaction_id']; + $sql = "SELECT * FROM thankyou_a_b WHERE transaction_id = '$transaction_id'"; + $res = $app->eclipse_sql($sql); + if (is_numeric($amount) && mysql_num_rows($res) === 0) { + $sql = "INSERT INTO thankyou_a_b VALUES (NOW(), '$test', $amount, '$transaction_id')"; $app->eclipse_sql($sql); } }