Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Bank.php

  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Location
    Doncaster
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Bank.php

    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

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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?
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    New Coder
    Join Date
    Sep 2002
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    <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:
    PHP Code:
    <?
    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.

  • #4
    New Coder
    Join Date
    Sep 2002
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •