Re: My Project

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Paul Waring wrote:
On Tue, Jul 19, 2005 at 09:50:06AM -0700, George B wrote:

My money is being stored in a database. And I want everythign to be in PHP, no java script. And the BUY!! Button is a input button from a form. :)


Well in that case you probably want something like this (after you've
checked to see whether the user is logged in etc):

$sql = "UPDATE users SET money = money - 10 WHERE id = " .
$_SESSION['user_id'];

this does not check if the user has enough money. This query does:

UPDATE users SET money = money - 10 WHERE id = $_SESSION['user_id'] and money >= 10

Then check affected rows to see if the money was actually subtructed from the account.

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux