There was such a problem, there is a transfer function on the site, but I can transfer the balance to any person except myself by typing any amount absolutely, it will go to me in a minus, and the person to whom I send it comes. How to make it so that the balance is checked, and if it is less than the amount claimed or less than zero, then an error has come out that this cannot be done, or if the balance is greater than or equal to the amount to be transferred, then it would be successfully transferred. Here is the code:
if($row['login'] != $nick) { $fa = 'error'; $error = 'Пользователь не найден'; }else { if($rowa['login'] == $nick){ $fa = 'error'; $error = 'Вы не можете перевести самому себе'; }else { if(!preg_match("/^[0-9]+$/", $summa)){ $fa = 'error'; $error = 'Сумма заполнено неверно'; }else { if($summa < 10) { $fa = 'error'; $error = 'Минимальная сумма перевода 10 '.$walletsite.''; }else { $update_sql = "Update ".$prefix."_users set balance=balance + '$summa' WHERE login='$nick'"; mysql_query($update_sql) or die("" . mysql_error()); $update_sql = "Update ".$prefix."_users set balance=balance - '$summa' WHERE hash='$sid'"; mysql_query($update_sql) or die("" . mysql_error()); $fa = 'success'; $error = 'Вы перевели '.$summa.' '.$walletsite.' пользователю '.$nick.''; $sql_selects = "SELECT * FROM ".$prefix."_users WHERE hash='$sid'"; $results = mysql_query($sql_selects); $rows = mysql_fetch_array($results); $new_balance = $rows['balance']; } } } }