I'm trying to implement a bank system on a game project of mine. I'm having a problem with elseif
.
I have this code:
<?php
session_start();
include ('include/dbconnect.php');
$res = mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
$userRow = mysql_fetch_array($res);
$in = $_POST['entrar'];
$pocketremain = ($userRow['money'] - $in);
$bankremain = ($userRow['bank'] + $in);
if ($in < $userRow['money']) {
// QUERIES
mysql_query("UPDATE users SET money ='".$pocketremain."' WHERE user_id ='".$_SESSION['user']."'");
mysql_query("UPDATE users SET bank ='".$bankremain."' WHERE user_id ='".$_SESSION['user']."'");
$string = "<br><font size='2'><font color='green'>SUCCESS !! </font><br>You deposited $in$.<br>You now have $bankremain$ in the Bank<br>and $pocketremain$ in your Pocket.</font>";
} elseif ($in <= '0') { // FIM DE QUERIES
$string = "<br><font size='2'><font color='red'>FAIL !!</font> <br>You cant deposit imaginary money!</font>";
} else {
$string = "<br><font size='2'><font color='red'>FAIL !!</font> <br>Your values are Wrong!</font>";
}
?>
I still can depoisit Zero money in the bank. elseif
should be stating that $string
if 0 was set as value.
If you could kill this for me I would appreciate, i have been trying to work around this for hours now.