[HELP] Vip_points transfer system :)

Vaulient1

New Member
Jan 17, 2013
11
1
Code:
[LIST=1]
[*][COLOR=#000000]<?php[/COLOR]
[*][COLOR=#000000]        if(isset($_POST['send'])){ // If the form has been submitted.[/COLOR]
[*][COLOR=#000000]       [/COLOR]
[*][COLOR=#000000]        $to = $_POST['to'];[/COLOR]
[*][COLOR=#000000]        $from = $_POST['from'];[/COLOR]
[*][COLOR=#000000]        $amount = $_POST['amount'];[/COLOR]
[*][COLOR=#000000]       [/COLOR]
[*][COLOR=#000000]    $from_sql = "UPDATE users SET vip_points = vip_points - $amount WHERE username='$from'";[/COLOR]
[*][COLOR=#000000]    mysql_query($from_sql);[/COLOR]
[*][COLOR=#000000]    $to_sql = "UPDATE users SET vip_points = vip_points + $amount  WHERE username='$to'";[/COLOR]
[*][COLOR=#000000]    mysql_query($to_sql);[/COLOR]
[*][COLOR=#000000]    }[/COLOR]
[*][COLOR=#000000] [/COLOR]
[*][COLOR=#000000]?>[/COLOR]
[*][COLOR=#000000]<form method="post" action="">[/COLOR]
[*][COLOR=#000000]    <input name="from" type="hidden" value="{username}">[/COLOR]
[*][COLOR=#000000]    Amount: <input name="amount" type="text"><br>[/COLOR]
[*][COLOR=#000000]    To: <input name="to" type="text"><br>[/COLOR]
[*][COLOR=#000000]    <input type="submit" name="send" value="Transfer" />[/COLOR]
[*][COLOR=#000000]</form>
[/COLOR]
Hey guys , thanks for reading my thread , I love you all ^-^ Well you see that php code works efficiently but one problem though , it lets us send how amny vip_points to another user and causing this
you see? -50? Well could anybody of you guys help me to preevent it from deductiong more than 0? Make it to give a warning or a notification saying "you do not have enough shells".
I would be glad if you helped , thank you :)
[/LIST]
 

Lotus

Legacy, it's all anyone leaves behind.
Jun 8, 2012
1,637
501
lmao I got this before simple its taking away and adding. command: :shell (username) +50 for Positive Credits, Pixels, Or Shells, For Negative :shell (username) -50
 

Ecko

23:37 [autobots] -!- eckostylez [[email protected]]
Nov 25, 2012
1,396
960
Run a query to grab how many points the user who is sending them has:

$query = "SELECT `vip_points` FROM users WHERE username = '$from';
$points = mysql_query($query);

Then an if check to see if the amount is more than what the user has:

if $points > $amount {
echo 'You do not have that many points to transfer.';
} else { run other queries to transfer points.
 

Users who are viewing this thread

Top