...

View Full Version : Bank.php



antoheley
12-30-2003, 10:23 PM
Hi is there anything wrong with this code because it dont seem to work on my game.

<body bgcolor="#000000">
<?php $title = "Bank"; include("header.php"); ?>

<font color="#00CC66">Welcome to the bank, $user. You can deposit your extra credits in here, to avoid having them stolen by attackers.</colour>


<?php

if ($action == with) {

if ($with > $stat[bank] || $with <= 0) {

print "You cannot withdraw that amount.";

include("footer2.php");

exit;

}



mysql_query("update players set cash=cash+$with where id=$stat[id]");

mysql_query("update players set bank=bank-$with where id=$stat[id]");

print "You withdrew $with cash.";

}



if ($action == deposit) {

if ($dep > $stat[cash] || $dep <= 0) {

print "You cannot withdraw that amount.";

include("footer2.php");

exit;

}



mysql_query("update players set cash=cash-$dep where id=$stat[id]");

mysql_query("update players set bank=bank+$dep where id=$stat[id]");

print "You deposited $dep credits.";

}

}

?>

<form method=post action=bank.php?action=withdraw>

<?php

print "I will <input type=submit value=withdraw> <input type=text value=$stat[bank] name=with> credits.";

?>

</form>



<form method=post action=bank.php?action=deposit>

<?php

print "I will <input type=submit value=deposit> <input type=text value=$stat[credits] name=dep> credits.";

?>

</form>

<?php include("footer.php"); ?>

please help.

thanks alot

anto

Spookster
12-30-2003, 10:37 PM
There are many things wrong with that code, more than I have time to list out for you. What is it you are trying to do?

Temper
12-30-2003, 10:41 PM
<font color="#00CC66">Welcome to the bank, <? echo $user; ?>.
You can deposit your extra credits in here, to avoid having them stolen by attackers.</colour>


and the with and deposite need to be in quotes:


<?
if ($action == "with")

if ($action == "deposit")
?>


I'm not really sure about the mysql queries, but I can't correct it, because I'm still pretty new at this stuff.
;)

Temper
12-30-2003, 10:44 PM
What I gather from it, he's making a game of some sort that allows you to deposit and withdraw money from a bank. I'm imagining he has a selection box with Deposit and Withdraw as options and make the variables $dep and $with. Then he wants them to update in the mysql queries, but I don't know how to properly help him there.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum