burtybob Posted September 12, 2007 Share Posted September 12, 2007 Ok... I have a problem and can i say firstly i dont want code but an explanation on how to do this, i would like to know how can i make a bank script have a button(which i have got) but then one says Deposit all and the other one says Withdraw all, How would i go about making it so that they do exactly what it says on the button, would it be that i treat the buttons like a normal part of the form? or how? Please dont post code as i would like to code it fully myself although if you need to post code to make it easier to explain please feel free. Quote Link to comment https://forums.phpfreaks.com/topic/69079-deposit-all-into-bank-scripts/ Share on other sites More sharing options...
cooldude832 Posted September 12, 2007 Share Posted September 12, 2007 Are you talking about a game money or real money. Either way the button servers the same purpose as a link would, except it allows you to send post data vs get data which is what you want to do. The button would be an onclick submit and set the value to withdraw/deposit. Then it would run a query in mysql adjusting the values accordingly. However you would want to make sure the script was secure so that it wouldn't move money until verification of previous values was made. Quote Link to comment https://forums.phpfreaks.com/topic/69079-deposit-all-into-bank-scripts/#findComment-347239 Share on other sites More sharing options...
burtybob Posted September 13, 2007 Author Share Posted September 13, 2007 I have got the bit that updaates the mysql database but it doesnt do it, i have if (!empty($buttonvariable)){ update the database } Rest of code To put it simply. but it doenst update the database and btw it is game money. Quote Link to comment https://forums.phpfreaks.com/topic/69079-deposit-all-into-bank-scripts/#findComment-347856 Share on other sites More sharing options...
Jessica Posted September 13, 2007 Share Posted September 13, 2007 Your buttons should have each their own name and value. Check which was set using isset(). Then take the appropriate action Quote Link to comment https://forums.phpfreaks.com/topic/69079-deposit-all-into-bank-scripts/#findComment-347860 Share on other sites More sharing options...
burtybob Posted September 13, 2007 Author Share Posted September 13, 2007 Your buttons should have each their own name and value. Check which was set using isset(). Then take the appropriate action so basicall same as above but instead of (empty) use (isset)? Quote Link to comment https://forums.phpfreaks.com/topic/69079-deposit-all-into-bank-scripts/#findComment-347874 Share on other sites More sharing options...
burtybob Posted September 13, 2007 Author Share Posted September 13, 2007 Your buttons should have each their own name and value. Check which was set using isset(). Then take the appropriate action so basicall same as above but instead of (empty) use (isset)? This works mostly but it deposits it and then withdrawable but it doesnt display that it has done either in the ballance area. Ok heres the code i am using. if (isset($depall)) { $allmony = mysql_query("SELECT money FROM members WHERE userid = $c_userid"); mysql_query("UPDATE members SET `bankmoney`=$allmony,`money`='0',`banktime`='$outtime' WHERE `userid`='$c_userid'"); } else if(isset($witall)) { $allmonya = mysql_query("SELECT bankmoney FROM members WHERE userid = $c_userid"); mysql_query("UPDATE members SET `money`=money+'$allmonya',`bankmoney`='0' WHERE `userid`='$c_userid'"); } else { Quote Link to comment https://forums.phpfreaks.com/topic/69079-deposit-all-into-bank-scripts/#findComment-347885 Share on other sites More sharing options...
Jessica Posted September 13, 2007 Share Posted September 13, 2007 you're not telling it to display anything... Quote Link to comment https://forums.phpfreaks.com/topic/69079-deposit-all-into-bank-scripts/#findComment-347888 Share on other sites More sharing options...
cooldude832 Posted September 13, 2007 Share Posted September 13, 2007 I'd suggest you create a log table also to say each time a bank deposit is made log it. Quote Link to comment https://forums.phpfreaks.com/topic/69079-deposit-all-into-bank-scripts/#findComment-347970 Share on other sites More sharing options...
burtybob Posted September 14, 2007 Author Share Posted September 14, 2007 Ok... Here is my ENTIRE Code for the bank page. <?php include("dbconnect.php"); include("playerchecks.php"); include("checkhospjail.php"); include("fn_sendmessage.php"); if (empty($c_userid)) { header("Location: index.php"); exit; } else { /********************************************** ** GET PLAYERS EXISTING MONEY FOR DEPOSIT ALL** ***********************************************/ $gtaid=secureint($_POST['gtaid']); $depall=$_POST['depall']; $witall=$_POST['witall']; $fetch=mysql_fetch_array(mysql_query("SELECT * FROM members WHERE `userid`='$c_userid'")); $moneys=$fetch[money]; /*************************************** ** GET PLAYER'S EXISTING BANK BALANCE ** ***************************************/ $fetch=mysql_fetch_array(mysql_query("SELECT * FROM members WHERE `userid`='$c_userid'")); $bankmoney=$fetch[bankmoney]; $banktime=$fetch[banktime]; $bankremain=$banktime-time(); $moneys=$fetch[money]; /*************************************************** ** CHECK IF 24 HOURS HAS EXPIRED AND ADD INTEREST ** ***************************************************/ if ($bankremain<=0) { $plmoney+=$bankmoney+($bankmoney-intval($bankmoney*1.05)); $bankmoney=0; $banktime=0; $bankremain=0; } /************************************** ** PLAYER WANTS TO USE THEIR ACCOUNT ** **************************************/ $outtime=time()+(24*60*60); //24 hours if (isset($depall)) { $allmony = mysql_query("SELECT money FROM members WHERE userid = $c_userid"); mysql_query("UPDATE members SET `bankmoney`=$allmony,`money`='0',`banktime`='$outtime' WHERE `userid`='$c_userid'"); } else if(isset($witall)) { $allmonya = mysql_query("SELECT bankmoney FROM members WHERE userid = $c_userid"); mysql_query("UPDATE members SET `money`=money+'$allmonya',`bankmoney`='0' WHERE `userid`='$c_userid'"); } else { if ($_POST['subbalance']) { $amount=secureint($_POST['amount']); if ($amount>0) { $action=secureint($_POST['action']); if ($action==1) { //Player wants to credit their account if ($plmoney<$amount) {$message="You can't credit your account with money you don't have";} else { $outtime=time()+(24*60*60); //24 hours $plmoney-=$amount; //Remove money from the player's hand if ($bankmoney>0) {//Player wants to credit an existing balance mysql_query("UPDATE members SET `money`=money-'$amount',`bankmoney`=bankmoney+'$amount',`banktime`='$outtime' WHERE `userid`='$c_userid'"); $message="You added $".number_format($amount)." to your account - in 24 hours you'll receive 5% interest"; $bankmoney+=$amount; } else { mysql_query("UPDATE members SET `money`=money-'$amount',`bankmoney`='$amount',`banktime`='$outtime' WHERE `userid`='$c_userid'"); $message="You credited your account with $".number_format($amount)." - in 24 hours you'll receive 5% interest"; $bankmoney=$amount; } } $bankremain=(24*60*60)-1; } else { //Player wants to debit their account if ($amount>$bankmoney) {$message="You don't have that much in your account";} else { if ($amount<$bankmoney) { //Player wants to withdraw some of their money mysql_query("UPDATE members SET `money`=money+'$amount',`bankmoney`=bankmoney-'$amount' WHERE `userid`='$c_userid'"); $message="You debited $".number_format($amount)." from your account"; $bankmoney-=$amount; } else { //Player wants to withdraw all of their money mysql_query("UPDATE members SET `money`=money+'$amount',`bankmoney`='0',`banktime`='0' WHERE `userid`='$c_userid'"); $message="You withdrew all your money from your account"; $bankmoney=0; $bankremain=0; } } } } else {$message="Invalid amount - please try again";} } } /************************************ ** PLAYER WANTS TO SEND SOME MONEY ** ************************************/ if ($_POST['subsend']) { $sendname=securestr($_POST['sendname']); if (empty($sendname)) {$message="You need to specify who you want to give to";} else { $fetch=mysql_fetch_array(mysql_query("SELECT displayname FROM members WHERE `displayname`='$sendname'")); $sendname=$fetch[displayname]; if (empty($sendname)) {$message="That player doesn't exist";} else { $sendamount=secureint($_POST['sendamount']); if ($_POST['sendmessage']) {$sendmsg=true;} else {$sendmsg=false;} if ($sendamount<100||$sendamount>$plmoney) {$message="Invalid amount - please try again";} else { $checkcode=md5(secureint($_POST['chkcode'])); if ($checkcode==$_SESSION['vcode']) { mysql_query("UPDATE members SET `money`=money-'$sendamount' WHERE `userid`='$c_userid'"); //Remove money "from" $receiveamount=intval($sendamount*0.9); mysql_query("UPDATE members SET `money`=money+'$receiveamount' WHERE `displayname`='$sendname'"); //Give money "to" mysql_query("INSERT INTO banktransfers (`from`,`to`,`amount`,`dt`) VALUES ('$plname','$sendname','$sendamount',NOW() )"); $message='You sent <a href="viewprofile.php?user='.$sendname.'">'.$sendname.'</a> $'.number_format($sendamount).', after bank charges they received $'.number_format($receiveamount); if ($sendmsg) { $sendmsg='sent you $'.number_format($sendamount).'.\n\nAfter bank charges you received $'.number_format($receiveamount).'.'; sendmessage($plname,$sendname,$sendmsg,5); } } else {$message="The code doesn't verify - please try again";} } } } } /*********************************** ** GET LAST 10 BANK TRANSFERS OUT ** ***********************************/ $outhtml=""; $query=mysql_query("SELECT * FROM banktransfers WHERE `from`='$plname' ORDER BY `dt` DESC LIMIT 10"); while ($fetch=mysql_fetch_array($query)) { $outhtml.='<tr class="tblin"><td class="gtext"><a href="viewprofile.php?user='.$fetch[to].'">'.$fetch[to].'</a></td><td class="gtextr">$'.number_format($fetch[amount]).'</td><td class="gtextc">'.gmdate("d-m \a\\t H:i",strtotime($fetch[dt])).'</td></tr>'; } /********************************** ** GET LAST 10 BANK TRANSFERS IN ** **********************************/ $inhtml=""; $query=mysql_query("SELECT * FROM banktransfers WHERE `to`='$plname' ORDER BY `dt` DESC LIMIT 10"); while ($fetch=mysql_fetch_array($query)) { $inhtml.='<tr class="tblin"><td class="gtext"><a href="viewprofile.php?user='.$fetch[from].'">'.$fetch[from].'</a></td><td class="gtextr">$'.number_format($fetch[amount]).'</td><td class="gtextc">'.gmdate("d-m \a\\t H:i",strtotime($fetch[dt])).'</td></tr>'; } echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Lealta alla Famiglia :: Game Information</title> <link rel="stylesheet" type="text/css" href="main.css" /> <script language="JavaScript" type="text/javascript""> function doFocus() { document.myform.amount.focus(); } </script> </head> <body onload="doFocus();" onmouseover="window.status='Lealta alla Famiglia :: Bank';return true;" onmouseout="window.status='';return true;"> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr><td colspan="3"><?php include("titlebar.php"); ?></td></tr> <tr><td colspan="3"><hr></td></tr> <tr> <td width="130" valign="top" align="left"><?php include("menu.php"); ?></td> <td valign="top" class="playarea" align="center" width="100%"> <br /><?=$message?><br /><br /> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="myform"> <table cellspacing="0" cellpadding="0" border="0"> <tr><td align="center" valign="top"> <table cellspacing="0" cellpadding="0" class="tblout"> <tr class="tblin"><td class="tblhdr" colspan="2">Bank</td></tr> <tr class="tblin"><td class="gtext">Balance</td><td class="gtext">$<?php echo number_format($bankmoney); ?></td></tr> <tr class="tblin"><td class="gtext">Time Left</td><td class="gtext"><?php if ($bankremain<0) {echo "00:00:00";} else {echo gmdate("H:i:s",$bankremain);} ?></td></tr> <tr class="tblin"><td class="gtext">Amount</td><td class="gtext"><input type="text" name="amount" size="16" maxlength="10" class="textbox" /></td></tr> <tr class="tblin"><td class="gtext">Action</td><td class="gtext"><input type="radio" name="action" value="1" checked="checked" /> Credit <input type="radio" name="action" value="2" /> Debit</td></tr> <tr class="tblin"><td class="gtextc" colspan="2"><input type="submit" name="subbalance" value=" Make Transaction " class="button" /></td></tr> <tr class="tblin"><td class="gtextc" colspan="2"><input type="submit" name="depall" value=" Deposit All" class="button" /></td></tr> <tr class="tblin"><td class="gtextc" colspan="2"><input type="submit" name="witall" value=" Withdraw All" class="button" /></td></tr> </table><br /> <table cellspacing="0" cellpadding="0" class="tblout"> <tr class="tblin"><td class="tblhdr" colspan="2">Transfer Money</td></tr> <tr class="tblin"><td class="gtext">Who to?</td><td class="gtext"><input type="text" name="sendname" size="21" maxlength="20" class="textbox" /></td></tr> <tr class="tblin"><td class="gtext">Amount</td><td class="gtext"><input type="text" name="sendamount" size="16" maxlength="10" class="textbox" /></td></tr> <tr class="tblin"><td class="gtext">Message</td><td class="gtext"><input type="checkbox" name="sendmessage" /></td></tr> <tr class="tblin"><td class="gtextc" colspan="2">Enter verification code:<br /><img src="verifycode.php" width="55" height="15" border="0" /> <input type="text" name="chkcode" size="7" maxlength="6" class="textbox" /></td></tr> <tr class="tblin"><td class="gtextc" colspan="2"><input type="submit" name="subsend" value=" Send " class="button" /></td></tr> </table> </td> <td width="18"> </td> <td align="center" valign="top"> <?php if (!empty($outhtml)) { ?> <table cellspacing="0" cellpadding="0" class="tblout"> <tr class="tblin"><td class="tblhdr" colspan="3">Last 10 Outgoing</td></tr> <tr class="tblin"><td class="gsubhdr">Name</td><td class="gsubhdr">Amount</td><td class="gsubhdr">When</td></tr> <?=$outhtml?> </table><br /> <?php } ?> <?php if (!empty($inhtml)) { ?> <table cellspacing="0" cellpadding="0" class="tblout"> <tr class="tblin"><td class="tblhdr" colspan="3">Last 10 Incoming</td></tr> <tr class="tblin"><td class="gsubhdr">Name</td><td class="gsubhdr">Amount</td><td class="gsubhdr">When</td></tr> <?=$inhtml?> </table> <?php } ?> </td></tr> </table> </form> </td> </tr> </table> </body> </html> <?php } ?> I have tried several things and i can only ever get parts to work like deposit or bank time or neither to work.... And i allready have the db with time and that to log it, that works as long as it isnt via the buttons of dep/wit all. Quote Link to comment https://forums.phpfreaks.com/topic/69079-deposit-all-into-bank-scripts/#findComment-348442 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.