I have a form where 2 users can transfer funds to each other.
Here is my code
$accountfrom=$_POST[accountfrom];
$accountto=$_POST[accountto];
$amount=$_POST[amount];
$result = mysql_query("UPDATE member
SET balance = IF(personID = $accountfrom, balance-$amount, balance+$amount)
WHERE personID IN ($accountfrom, $accountto)")
or die(mysql_error());
However if the user only has a balance of £10, this allows them to still trasfer more than they have available. Is there a way to stop this?
(the balance is stored in field named balance
)