AdamHull12 Posted February 26, 2015 Share Posted February 26, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/294920-function-not-working-correctly/ Share on other sites More sharing options...
ginerjm Posted February 26, 2015 Share Posted February 26, 2015 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) Quote Link to comment https://forums.phpfreaks.com/topic/294920-function-not-working-correctly/#findComment-1506853 Share on other sites More sharing options...
AdamHull12 Posted February 26, 2015 Author Share Posted February 26, 2015 1) Yes it is in test.php, 2)if the if statement is false then it will not pass down into the else statement it just prints the if no matter what. 3) I have put in the php error checking and nothing is displayed Quote Link to comment https://forums.phpfreaks.com/topic/294920-function-not-working-correctly/#findComment-1506856 Share on other sites More sharing options...
Ch0cu3r Posted February 26, 2015 Share Posted February 26, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/294920-function-not-working-correctly/#findComment-1506858 Share on other sites More sharing options...
ginerjm Posted February 26, 2015 Share Posted February 26, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/294920-function-not-working-correctly/#findComment-1506859 Share on other sites More sharing options...
AdamHull12 Posted February 26, 2015 Author Share Posted February 26, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/294920-function-not-working-correctly/#findComment-1506860 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.