Still bangin my head
| From: | Jennifer Downey | Date: | Mon, 25 Feb 2002 09:00:13 +0000 |
| Subject: | Still bangin my head | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-17255@lists.php.net to get a copy of this message | ||
Hi all,
I'm still banging my head on this.
Let's say I have $1000 to withdraw from my account. I withdraw that $1000
which leaves me $0 dollars in the account.
With the code below if I enter another $1000 dollars in the form and hit
enter it loans me the thousand and puts my account at -$1000 dollars.
What do I need to do to stop it from loaning me the thousand and keep me
from having a negative balance?
<TABLE BORDER="0" WIDTH="25%" CELLPADDING="0"
CELLSPACING="0">
<TR>
<TD><font size="2">Withdraw</font></TD>
<TD> <INPUT TYPE="text" VALUE=""
NAME="user_withdraw"></TD>
</TR>
<TR>
<TD></TD>
<TD><INPUT TYPE="submit" VALUE="Make My Withdrawal"
NAME="withdraw"></TD>
</TR>
</TABLE>
</FORM>
// used to update if a user makes a withdrawal
$query = ("UPDATE wt_users set bank_points = bank_points - $user_withdraw,
points = points + $user_withdraw WHERE uid={$session["uid"]}");
$result=mysql_query("$query");
// select bank points for the user.
$sql_result = mysql_query("SELECT bank_points FROM wt_users WHERE
uid={$session["uid"]}");
$row = mysql_fetch_array($sql_result);
// if bank points are at 0 then print no points and quit.
if ($sql_result <= "0") {
echo "you don't have that many points";
exit;
} else {
echo "Your withdraw has been made!";
Thanks again in advance
Jennifer Downey