i have the code of my POST action , but is very long , with two different actions , if the user has the card to buy with money from the vault , and if the user has not the card upgrade the code is something like this :
if (isset($_POST['shop'])) {
if (security($_POST['ccard']) == 1) {
$umoney = $urow['bank'] + $urow['money'];
} else {
$umoney = $urow['money'];
}
mysql_query(set the total upgrade values in another table)
mysql_query(give the user upgrade values in another table)
}
if (security($_POST['ccard']) == 1) {
$upuser = mysql_query("UPDATE `users` SET bank=bank-'$sumtotc' WHERE id='$urow[id]'");
} else {
$upat2 = mysql_query("UPDATE `users` SET money=money-'$sumtotc' WHERE id='$urow[id]'");
}
but if i do so , if the user buy something that the value is more than bank , it will be with minus value in bank , i tried with this :
if ($urow['bank'] < 0) {
$upmon = mysql_query("UPDATE `users` SET money=money-'$urow[bank]' WHERE id='$urow[id]'");
$upban = mysql_query("UPDATE `users` SET bank=0 WHERE id='$urow[id]'");
}
Is there another way to make the ccard funtion better? and the value of the bank not to be negative ?