Jump to content

Simple Bank


Dethman

Recommended Posts

I need help with this script I coded it dosnt work but the original I created for my Training works fine....

 

<?

include "vsys.php";

$user=getUserDetails($_SESSION['isLogined'],"*");

if($cgi[bank]){

 

if($cgi[deposit]){

$wal=$cgi[deposit];$typ=0;

$detail.=deposit($user,$typ);

}

if($cgi[withdrawl]){

$wal=$cgi[withdrawl];$typ=1;

$detail.=withdrrew($user,$typ);

}

//echo "--$typ--";

header("Location: bank.php?strErr=$detail");

}

?>

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<!-- saved from url=(0036)http://www.strek-vs-sgate.com/base.php -->

<HTML><HEAD><TITLE>Wars of Halo ::

<? $user=getUserDetails($_SESSION['isLogined'],'userName');echo $user->userName; ?>

s Outpost Vault</TITLE>

<META http-equiv=Content-Type content="text/html; charset=iso-8859-1"><!-- ZoneLabs Privacy Insertion -->

<SCRIPT language=javascript src="js/js"></SCRIPT>

<LINK href="css/common.css" type=text/css rel=stylesheet><LINK

href="css/Elves.css" type=text/css rel=stylesheet>

<META

content="kingsofchaos, chaos, elves, humans, dwarves, orcs, rpg, mmorpg, role playing, game, online game, text based game, armory, mercenaries, spy, attack, army, battle, recruit, spies, spy skill, weapons, messaging, sabotage, recon, intelligence, pnp, mud, games, stockade, free, browser game"

name=keywords>

<META

content="Kings of Chaos is a Massively Multiplayer Online Role Playing Game with over 500,000 players. Players can choose one of four races: Orcs, Humans,  Elves and Dwarves and build armies, recruit friends as officers, buy weapons, and spy and attack on each other."

name=description>

<META content="Kings of Chaos" name=author>

<SCRIPT language=javascript type=text/javascript>

<!--

function checkCR(evt) {

var evt = (evt) ? evt : ((event) ? event : null);

var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);

if ((evt.keyCode == 13) && (node.type=="text")) {return false;}

}

document.onkeypress = checkCR;

//-->

</SCRIPT>

 

<META content="MSHTML 5.50.4522.1800" name=GENERATOR></HEAD>

<BODY text=#ffffff bgColor=#000000 leftMargin=3 topMargin=3 marginheight="3"

marginwidth="0">

<?

include "top.php";

?>

 

<TABLE cellSpacing=0 cellPadding=5 width="100%" border=0>

  <TBODY>

  <TR>

    <TD class=menu_cell style="PADDING-LEFT: 15px" vAlign=top width=140>

<?

include ("left.php");

?>

</TD>

      <TD style="PADDING-RIGHT: 15px; PADDING-LEFT: 15px; PADDING-TOP: 12px"

    vAlign=top align=left> <BR>

<?

include "islogined.php";

//$user=getUserDetails($_SESSION['isLogined']);

//$userR=getUserRanks($_SESSION['isLogined']);

?>

      <TABLE width="100%">

        <TBODY>

        <TR>

 

 

<TD vAlign=top width="50%">

            <FORM action=bank.php?do=deposit method=post>

            <TABLE class=table_lines cellSpacing=0 cellPadding=6 width="100%"

            border=0>

              <TBODY>

              <TR>

                <TH align=middle colSpan=3>Deposit/Withdrawl</TH></TR>

              <TR>

                <TH class=subh align=left>5% is taken each time you Deposit</TH>

                <TH class=subh align=right>Cost Per Unit</TH>

                <TH class=subh>Quantity</TH></TR>

              <TR>

                <TD>Deposit</TD>

                <TD align=middle><INPUT size=10 value=0

              name=deposit></TD></TR>

  <TR>

                <TD>Withdrawl</TD>

                <TD align=middle><INPUT size=10 value=0

              name=withdrawl></TD></TR>

         

              <TR>

                <TD align=middle colSpan=3><INPUT type=submit value=Deposit! name=deposit>

                <TD align=middle colSpan=3><INPUT type=submit value=Withdrawl! name=withdrawl>

              </TD></TR></TBODY></TABLE><INPUT type=hidden

            value=93aa2b6a02603399396203313b45827e name=hash> </FORM><BR></TD></TR>

</TABLE>

<div align="center">

<br>

<FONT style="FONT-SIZE: 8pt">     

and the actuall code for the making it work part is...

function Bank($user,$wal,$type)

{

$noNaquadah="You do not have that amount to put in the Bank";

$nosold="Not enough Naquadah!";

if($type==0){

$q = @mysql_query("select gold from `UserDetails` where ID='$user->ID' ");

$el=mysql_fetch_array($q, MYSQL_ASSOC);

if($el[gold])$q = @mysql_query("update `UserDetails` set Bank=Bank+'$wal', gold=gold-'$wal' where ID='$user->ID' ");

}

elseif($type==1){

$q = @mysql_query("select Bank from `UserDetails` where ID='$user->ID' ");

$el=mysql_fetch_array($q, MYSQL_ASSOC);

if($el[bank])$q = @mysql_query("update `UserDetails` set Bank=Bank-'$wal', gold=gold+'$wal' where ID='$user->ID' ");

}}

Link to comment
Share on other sites

What error are you getting?

I would also encourage you to consider programming in objects

e.g.

 

class Bank {

  public function getAccount( $user_id ) {
    // check if user is real and exists. is their pin number correct?
    // if they are real, return an Account object.
  }

  public function withdraw($amt, $act) {
    // withdraw an amount from the account specified
  }

  public function deposit($amt, $fromAct, $toAct) {
    // deposit an amount into the act
  }

}

 

then you can do

 

// Create a bank object.
$bank = new Bank();

// Get two accounts from the bank
$account1 = $bank->getAccount( 5 );
$account2 = $bank->getAccount( 34 );

// Deposit 1000 credits from account1 to account2
$bank->deposit( 1000 , $account1, $account2);

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.