Guys, welcome. There was a situation on the site that one of the users was able to bypass the check and steal funds. After viewing, I saw that the user had a negative balance in the database. Please help and make the thought in advance very grateful.
PHP:
$user = mysqli_fetch_assoc(mysqli_query($CONNECT, "SELECT * FROM `users` WHERE `login` = '$_SESSION[USER_LOGIN]'"));// сессия присваивается после авторизации $balance = $user['balance'];//переменная с данными пользователя if ( isset($_POST['cashout']) ) { if ( $_POST['amount'] >= 10 ) { if ( $_POST['amount'] <= $balance ) { // Здесь скрипт выполняющий вывод средств и обновляющий баланс в БД $balance_res = $balance - $_POST['amount']; mysqli_query($CONNECT, "UPDATE `users` SET `balance` = $balance_res WHERE `id` = '$us_id'"); MessageSend(2, 'Средства успешно выведены', '/cashout'); } else { MessageSend(1, 'Недостаточно средств', '/cashout'); } } else { MessageSend(1, 'Минимальная сумма 10 рублей.', '/cashout'); } } The form:
<form action="/cashout" method="POST"> Кому: <input type="text" class="form-control" name="payeer" placeholder="Payeer кошелек"> Сколько: <input type="number" name="amount" class="form-control" placeholder="Сумма в рублях"> <input type="submit" name="cashout" value="Cash Out"> </form>
cachouttable from code that does not refer to it ... You believe that this code was bypassed because only this code refers to thecachouttable. But this may be a false logical premise. - rugabarbo