you would need to do a select and find out how much is in the "account"
first, then do a check on the equation to see if the result is going to come
out negative - if it is, then either don't allow it, or give them an option
to clear the account or whatever, otherwise just go ahead and do the
withdrawl.

alternatively on the withdrawl screen, you could tell them how much is in
the account and only allow them to enter a value up to that amount
(javascript) which would kind of pre-empt their stupidity :)

HTH

beau

// -----Original Message-----
// From: Jennifer Downey [mailto:[EMAIL PROTECTED]]
// Sent: Monday, 25 February 2002 5:00 PM
// To: [EMAIL PROTECTED]
// Subject: [PHP-DB] Still bangin my head
// 
// 
// 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
// 
// 
// 
// -- 
// PHP Database Mailing List (http://www.php.net/)
// To unsubscribe, visit: http://www.php.net/unsub.php
// 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to