Good morning. I'm having a problem with elseif.
Im practicing trying to implement a bank system on a game project of mine. If you could help me with this little issue i would appreciate.
Take a peak:
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>";
}
// FIM DE QUERIES
elseif ($in <= '0') {
$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.
Thank you! Have a nice morning
Aucun commentaire:
Enregistrer un commentaire