"SET NAMES utf8", PDO::ATTR_PERSISTENT => false ) ); $_DB->setAttribute(PDO::ATTR_TIMEOUT, 1); } catch (Exception $e) { die; } $sign = md5($merchant . ':' . $amount . ':' . $enot_key . ':' . $merchant_id); if ($sign == $_POST['sign_2']) { $donationDatas = explode('_', $_REQUEST['custom_field']); $user_id = $donationDatas[0]; $points = $donationDatas[1]; $actual_points = 0; $new_points = 0; $rowExistQuery = $_DB->prepare('SELECT * FROM shop_coins WHERE id = :user'); $rowExistQuery->bindParam(':user', $user_id, PDO::PARAM_INT); $rowExistQuery->execute(); $rowExist = $rowExistQuery->fetchAll(PDO::FETCH_OBJ); /// Add if (count($rowExist) > 0) { $rowExist = $rowExist[0]; $actual_points = $rowExist->coins; $new_points = $rowExist->coins + $points; $updateCoinsQuery = $_DB->prepare('UPDATE shop_coins SET coins = :new_value WHERE id = :account'); $updateCoinsQuery->bindParam(':new_value', $new_points, PDO::PARAM_INT); $updateCoinsQuery->bindParam(':account', $user_id, PDO::PARAM_INT); $updateCoinsQuery->execute(); } else { $new_points = $points; $insertCoinsQuery = $_DB->prepare('INSERT INTO shop_coins(`id`, `coins`) VALUES(:account, :new_value)'); $insertCoinsQuery->bindParam(':account', $user_id, PDO::PARAM_INT); $insertCoinsQuery->bindParam(':new_value', $new_points, PDO::PARAM_INT); $insertCoinsQuery->execute(); } $typeToSave = 'payment'; $creditsToSave = $points; $sysToSave = 'enot'; $dateToSave = date("Y-m-d H:i:s"); /// HISTORY $historyType = "enot"; $historyQuery = $_DB->prepare('INSERT INTO shop_coins_history(`account_id`, `points`, `actual_points`, `new_points`, `type`, `system`, `reference`, `date`) VALUES(:account, :new_value, :actual, :new, :ty, :sys, :ref, :date)'); $historyQuery->bindParam(':account', $user_id, PDO::PARAM_INT); $historyQuery->bindParam(':new_value', $new_points, PDO::PARAM_INT); $historyQuery->bindParam(':actual', $actual_points, PDO::PARAM_INT); $historyQuery->bindParam(':new', $new_points, PDO::PARAM_INT); $historyQuery->bindParam(':ty', $typeToSave, PDO::PARAM_STR); $historyQuery->bindParam(':sys', $sysToSave, PDO::PARAM_STR); $historyQuery->bindParam(':ref', $historyType, PDO::PARAM_STR); $historyQuery->bindParam(':date', $dateToSave, PDO::PARAM_STR); $historyQuery->execute(); echo "OK"; return; } echo "NOT OK S"; } catch(Exception $e) { echo $e->getMessage(); }