Bank Charges [Resolved]
Posted: Wed Aug 21, 2013 9:16 pm
Hey all,
I've implemented a bank into the game I'm working on, but don't know how to setup a bank fee for deposits. I'm wanting to have a 10% charge on what they put into the bank. Any help would be appreciated. Below is the code:
I've implemented a bank into the game I'm working on, but don't know how to setup a bank fee for deposits. I'm wanting to have a 10% charge on what they put into the bank. Any help would be appreciated. Below is the code:
Code: Select all
<?php
session_start();
include("header.php");
if(!isset($_SESSION['uid'])){
echo "You must be logged in to view this page!";
}else{ ?>
<center>
<table width="90%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>Gold:</td>
<td><?php echo "Your balance is: " . $stats['bank'] . "<br>";?></td>
</tr>
<tr>
<td>Deposit</td>
<td>Amount:<fieldset>
<form method="post" action="bank.php" target="_self">
<input type="text" name="deposit" value="">
<input type="submit" name="bank_action" value="Deposit">
</form>
</fieldset>
</td>
</tr>
<tr>
<td>Withrawl</td>
<td>Amount:<fieldset>
<form method="post" action="bank.php" target="_self">
<input type="text" name="withdraw" value="">
<input type="submit" name="bank_action" value="Withdraw">
</form>
</fieldset>
</td>
</tr>
</table>
</center>
</div>
<?php
if (isset($_POST['deposit']))
{
if ($_POST['deposit'] > $stats['gold'] || $_POST['deposit'] < 0)
{
echo "You are trying to deposit too much. Try a smaller amount.";
}
else
{
$newbankd = ($stats['bank'] + $_POST['deposit']);
$newgoldd = ($stats['gold'] - $_POST['deposit']);
$bankdeposit = "update stats set bank='$newbankd', gold='$newgoldd' WHERE `id`='".$_SESSION['uid']."'";
mysql_query($bankdeposit) or die("could not update bank");
echo "You deposited your gold into the bank!";
}
}
else if (isset($_POST['withdraw']))
{
if ($_POST['withdraw'] > $stats['bank'] || $_POST['withdraw'] < 0)
{
echo "You do not have enough in your account.";
}
else
{
$newbankw = ($stats['bank'] - $_POST['withdraw']);
$newgoldw = ($stats['gold'] + $_POST['withdraw']);
$bankwithdraw = "update stats set bank='$newbankw', gold='$newgoldw' WHERE `id`='".$_SESSION['uid']."'";
mysql_query($bankwithdraw) or die("could not withdraw bank");
echo "You have withdrawn your gold!";
}
}
}
?>