This is the script i use for my bank script,
the only thing is: when i deposit say 25, and then withdraw 100, the account will go to -75, i don't want the bank to allow the money owned to go into minus figures,
If anyone could please help, thanxs, You will be added to the credits page if u help me.
Thanxs
<form method="post">
<input type=text name=price size=5>
<INPUT TYPE='hidden' NAME='level' size=10 value='1'><br>
<input type="radio" name="com" value="1">Withdraw<br>
<input type="radio" name="com" value="2">Deposite<br>
<input type=hidden name="submit" value=" Set ">
<input type=submit Value=Submit> <br>
You can not deposit all your money,<br>You Must have at least 1,
</form>
<?php
} else {
$userlist = file("users.inc.php");
$done = false;
$auth = false;
$found = false;
$i = 0;
while ((!$found) && ($i<count($userlist))) {
$i++;
list($n,$p,$a,$e,$g,$s,$m,$a1) = explode(':',$userlist[$i]);
$found = ($n==$user);
echo "<br>Please Wait...";
} if ($com == 2 && $m <= $price) { die("<br><b>Error: You don't have enough money</b><br>"); }
elseif (!$com) { die("<br><b>Error: You must select either Deposit or withdraw</b><br>"); }
elseif ($com == 1 && $a1 <= $price) { die("<br><b>Error: You don't have enough money</b><br>"); }
elseif ($com == 2 && $m >= $price) {
$m -= $price;
$a1 += $price;
$m = ($m < $price) ? $m : $m;
$a1 = ($m < $price) ? $a1 : $a1;
$userlist[$i] = implode(':',array($n,$p,$a,$e,$g,$s,$m,$a1));
$fd = fopen("users.inc.php","w");
fputs($fd,"<?php die(\"Access restricted\"); ?>\n");
for ($i=1; $i<count($userlist); $i++) {
fputs($fd,chop($userlist[$i])."\n");
}
fclose($fd);
echo "<script>window.opener.document.location.reload(); window.close();</script>";
}
elseif ($com == 1 && $a1 >= $price && $a1 >= 0) {
$m += $price;
$a1 -= $price;
$m = ($m < $price) ? $m : $m;
$a1 = ($a1 < $price) ? $a1 : $a1;
$userlist[$i] = implode(':',array($n,$p,$a,$e,$g,$s,$m,$a1));
$fd = fopen("users.inc.php","w");
fputs($fd,"<?php die(\"Access restricted\"); ?>\n");
for ($i=1; $i<count($userlist); $i++) {
fputs($fd,chop($userlist[$i])."\n");
}
fclose($fd);
echo "<script>window.opener.document.location.reload(); window.close();</script>";
}
}
?>