Jump to content

function not working correctly


AdamHull12

Recommended Posts

hello,

i have this function,

function withdraw() {
    global $db,$ir,$c,$userid;
    if($_POST['amount'] > $ir['bankmoney']) {
        echo '<span style="color:red;">You dont have enough money saved to withdraw that much!</span>';
    } else {
        $db->query("UPDATE `users` SET `bankmoney` = `bankmoney` - ".$_POST['amount'] .", `money` = `money` + " . $_POST['amount'] . " WHERE `userid` = ".$userid);
        $ir['money'] += $_POST['amount'];
        echo 'You withdrew ' . money_formatter($_POST['amount'] + 0) . ' into your hand from your account.<br/>
        You know have ' . money_formatter($ir['money'] + 0) . ' in your hand.';
    }
}

that does not seem to work correctly it will not seem to move past the first if statement even if the amount is less then the bank mone. the form which submits this is 

 <a href="test.php?withdraw" target="_blank">>Withdraw</a><br/>';
    if (isset($_GET['withdraw'])== 1){
    echo'
    <div id="withdraw" style="background: #ffffd3;border: 1px #ffff99 solid;padding: 20px;width: 250px;margin: 5px;">
        <form action="" method="post" onsubmit="makeTrans(\'withdraw\');return false;"><input type="text" name="withdraw" value="'.($ir['bankmoney']).'" /> <input type="submit" value="Withdraw" /></form>
        <div id="withdraw_callback">
            Please select the amount you wish to withdraw then hit the withdraw button next to it.
        </div>
    </div>
 
 ';

thanks

Link to comment
Share on other sites

1 - the withdraw function code - is that in test.php?

2 - you say it won't go past the first if statement in the withdraw function, but there isn't anything AFTER the if statement to go after. ??

3 - the second block of code is so incomplete and full of errors I won't even go into it. Turn on php error checking and re-run it. (see my signature)

Link to comment
Share on other sites

echo out your two amounts in the if statement message to be sure they are what you think they are.

Show us more of that code that shows us your error checking is on and shows where you have cleaned up the form code and php code around it. Obviously that is important to see and right now it does not make sense as it is being displayed.

Link to comment
Share on other sites

What are you doing here?

 onsubmit="makeTrans(\'withdraw\');return false;"

Are trying to call your withdraw function  here when the form submits? If so that will never work. You cannot call PHP functions from javascript.

yes that what is happening. This is someone elses codde i am trying to clean up

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.