Jump to content

Banking System,


HarleyJ

Recommended Posts

Hey guys, Im looking to create a banking system for my game. However I know very little about php.

 

http://www.flashmoron.com/valhallen is the game I wish to create a points system for.

 

I know how it should work But I have little clue of all the coding mumbo jumbo.

 

Get points from Database > If the amount of points held is less than what they are trying to deposit > Error message > Else if Amount of points held is more than they tried to deposit > Subtract Points from Database > Update bank database.

 

Thats basicly how it works I think, If anyone would be willing to tutor me, I would be very greatful.

 

[email protected]

Link to comment
https://forums.phpfreaks.com/topic/61177-banking-system/
Share on other sites

it would go something like this

 

<?php
// assume we're starting with these values
$deposit_amt = 500;
$userid = 'harleyj';


$sql = "SELECT points FROM banktable WHERE userid = '$userid' ";    // create the query
$res = mysql_query ($sql) or die(mysql_error());                    // execute the query, checking for errors
$points_held = mysql_result ($res, 0,0);                            // extract the points from the query results

// now check the values
if ($deposit_amt > $points_held) {
    echo "Sorry, insufficient points in bank";
}
else {
    $sql = "UPDATE banktable                                      
            SET points = points - $deposit_amt 
            WHERE userid = '$userid' ";                              // create update query
    mysql_query ($sql) or die(mysql_error());                        // execute
    echo "Deposit accepted and your points adjusted";
}
?>

 

BTW, are you sure you mean "deposit" and not "withdrawal"?

Link to comment
https://forums.phpfreaks.com/topic/61177-banking-system/#findComment-304539
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.