How do I do this?

Timothy

Kylie Jenner
Sep 25, 2013
674
79
I want to make it to were I can purchase like 5 thrones using vip_points but I don't know how, I can do it so u can purchase vip and credits but how do I do this?
CODE:
<?php
if (isset($_POST['throne']))
{
$vip_points = mysql_result(mysql_query("SELECT `vip_points` FROM `users` WHERE `id`='" . $_SESSION['user']['id'] . "'"), 0);
if ($vip_points < 500)
{
echo "<div style='margin-top: -12px; background: red; color: #fff; border-radius: 5px; padding: 5px; margin-bottom: -10px;'><font size='1'><center>Not enough points.</center></font></div>";
}
else
{
mysql_query("UPDATE `users` SET `vip_points`=`vip_points` - 500, credits = credits+200000 WHERE `id`='" . $_SESSION['user']['id'] . "' AND `vip_points` > - 500");
echo "<div style='margin-top: -12px; background: green; color: #fff; border-radius: 5px; padding: 5px; margin-bottom: -10px;'><font size='1'><center>Successful Purchase.</center></font></div>";
echo '<script type="application/javascript">slideDown();</script>';
echo '<script type="text/javascript">$(document).ready(function(){ $("#vpoints").html("Dine VIP-POENG: <strong>'.($vip_points-500).'</strong>"); });</script>';
}
}
?>

thanks in advanced :)
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
You can put it in your catalog if you set your snow to 4 and pixels to however many points you want them

But if you wanna do it this way I would set this up differently . Let me get on my laptop and I'll show you how t code it clean

Sent from iPhone
 

Timothy

Kylie Jenner
Sep 25, 2013
674
79
You can put it in your catalog if you set your snow to 4 and pixels to however many points you want them

But if you wanna do it this way I would set this up differently . Let me get on my laptop and I'll show you how t code it clean

Sent from iPhone
I'm already confused tbh with you, so please do show me. xD
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
Alright I am now on my computer. Okay so what you are trying to do from what I can tell is this:
You want to create a form to allow users to purchase 5 thrones from the CMS part.

Easiest way and will save you this stress is to create a catalog item and put it under any page or whatever
set the amount = 5 and set the cost_snow = 4 and cost_pixels = 500 (this will be 500 points)

Okay so how you will code this in php is like this:
PHP:
<?php
if (isset($_POST['throne']))
{
$cost = 500;
$grabID = dbquery("SELECT * FROM items ORDER BY id DESC LIMIT 0,1");
$fetchID = mysql_fetch_array($getidd);
$newID = $fetchID['id'] + 1;
$userInformation = mysql_query("SELECT * FROM users WHERE id = '" . $_SESSION['user']['id'] . "'");
while($info = mysql_fetch_array($userInformation)){
if($info['vip_points'] >= $cost){
    if($info['online'] == 0){
        mysql_query("UPDATE `users` SET vip_points = vip_points - $cost WHERE id = '" . $_SESSION['user']['id'] . "'");
        mysql_query("INSERT into items (id, user_id, room_id, base_item, x, y, z, rot, wall_pos) VALUES ('" . $newID . "','" . $_SESSION['user']['id'] . "', '0', 'THRONEID', '0', '0', '0', '0', '0')");
        echo "The Transaction was successful. You just purchased 5 thrones";
    }else{
        echo "Please be offline to make this transaction";
    }
}else{
    echo "The current cost is $cost and you only have $info['vip_points']";
}
}
}
?>
 

Timothy

Kylie Jenner
Sep 25, 2013
674
79
Alright I am now on my computer. Okay so what you are trying to do from what I can tell is this:
You want to create a form to allow users to purchase 5 thrones from the CMS part.

Easiest way and will save you this stress is to create a catalog item and put it under any page or whatever
set the amount = 5 and set the cost_snow = 4 and cost_pixels = 500 (this will be 500 points)

Okay so how you will code this in php is like this:
PHP:
<?php
if (isset($_POST['throne']))
{
$cost = 500;
$grabID = dbquery("SELECT * FROM items ORDER BY id DESC LIMIT 0,1");
$fetchID = mysql_fetch_array($getidd);
$newID = $fetchID['id'] + 1;
$userInformation = mysql_query("SELECT * FROM users WHERE id = '" . $_SESSION['user']['id'] . "'");
while($info = mysql_fetch_array($userInformation)){
if($info['vip_points'] >= $cost){
    if($info['online'] == 0){
        mysql_query("UPDATE `users` SET vip_points = vip_points - $cost WHERE id = '" . $_SESSION['user']['id'] . "'");
        mysql_query("INSERT into items (id, user_id, room_id, base_item, x, y, z, rot, wall_pos) VALUES ('" . $newID . "','" . $_SESSION['user']['id'] . "', '0', 'THRONEID', '0', '0', '0', '0', '0')");
        echo "The Transaction was successful. You just purchased 5 thrones";
    }else{
        echo "Please be offline to make this transaction";
    }
}else{
    echo "The current cost is $cost and you only have $info['vip_points']";
}
}
}
?>
didnt really work got white page but I did just take the " mysql_query("INSERT into items (id, user_id, room_id, base_item, x, y, z, rot, wall_pos) VALUES ('" . $newID . "','" . $_SESSION['user']['id'] . "', '0', "
and put it under " mysql_query("UPDATE `users` SET `cms_currency`=`cms_currency` - 500, credits = credits+200000 WHERE `id`='" . $_SESSION['user']['id'] . "' AND `cms_currency` > - 500"); " and worked perfectly. :)
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
didnt really work got white page but I did just take the " mysql_query("INSERT into items (id, user_id, room_id, base_item, x, y, z, rot, wall_pos) VALUES ('" . $newID . "','" . $_SESSION['user']['id'] . "', '0', "
and put it under " mysql_query("UPDATE `users` SET `cms_currency`=`cms_currency` - 500, credits = credits+200000 WHERE `id`='" . $_SESSION['user']['id'] . "' AND `cms_currency` > - 500"); " and worked perfectly. :)
Well I guess if that's all you get out of it whateve xD might have just been the echo $cost thing that was messing up. Oh well :) Enjoy
 

Users who are viewing this thread

Top