Jump to content
MakeWebGames

Point/Cash Exchange


Mark F
 Share

Recommended Posts

Hello everyone,

I have been trying to make a script where you are able to buy points for $1000, and sell them for $1000. Though I have been having a little trouble with the coding. I have so far tried to modify crystaltemple.php which allows you to trade points for cash, though I have had trouble trying to make it work vice versa. I would appreciate it if I could have some help modifying the script below.

 

<?php
include "globals.php";
if(!$_GET['spend'])
{
print "
<table cellspacing='1' border='0' cellpadding='3' class='table' width='30%'><tr>
<td colspan='1' class='h'>[b]You Have {$ir['crystals']} Points[/b]</td>
<td colspan='1' class='h'>[b]Purchase[/b]</td>
</tr>
<tr>
<td>\$".number_format($set['ct_moneypercrys'])." Money - 01 Points</td>
<td>[url='crystaltemple.php?spend=money']Purchase[/url]</td>
</tr>
<tr>
<td>Energy Refil - {$set['ct_refillprice']} Points</td>
<td>[url='crystaltemple.php?spend=refill']Purchase[/url]</td>
</tr>
</table>";
}
else
{
if($_GET['spend'] == 'refill')
{
if($ir['crystals'] <$set['ct_refillprice'])
{
print "You don't have enough Credits!";
}
else if($ir['energy'] == $ir['maxenergy'])
{
print "You already have full energy.";
}
else
{
$db->query("UPDATE users SET energy=maxenergy,crystals=crystals-{$set['ct_refillprice']} WHERE userid=$userid");
print "You have paid {$set['ct_refillprice']} Credits to refill your energy bar.";
}
}
else if($_GET['spend'] == 'IQ')
{
print "Type in the amount of Credits you want to swap for IQ.

You have [b]{$ir['crystals']}[/b] Credits.

One Credit = {$set['ct_iqpercrys']} IQ.<form action='crystaltemple.php?spend=IQ2' method='post'><input type='text' name='crystals' />
<input type='submit' value='Swap' /></form>";
}
else if($_GET['spend'] == 'IQ2')
{
$_POST['crystals']=(int) $_POST['crystals'];
if($_POST['crystals'] <= 0 || $_POST['crystals'] > $ir['crystals'])
{
print "Error, you either do not have enough Credits or did not fill out the form.

[url='crystaltemple.php?spend=IQ']Back[/url]";
}
else
{
$iqgain=$_POST['crystals']*$set['ct_iqpercrys'];
$db->query("UPDATE users SET crystals=crystals-{$_POST['crystals']} WHERE userid=$userid");
$db->query("UPDATE userstats SET IQ=IQ+$iqgain WHERE userid=$userid");
print "You traded {$_POST['crystals']} Credits for $iqgain IQ.";
}
}
else if($_GET['spend'] == 'money')
{
print "Type in the amount of Credits you want to swap for money.

You have [b]{$ir['crystals']}[/b] Credits.

One Credit = \$".number_format($set['ct_moneypercrys']).".<form action='crystaltemple.php?spend=money2' method='post'><input type='text' name='crystals' />
<input type='submit' value='Swap' /></form>";
}
else if($_GET['spend'] == 'money2')
{
$_POST['crystals']=(int) $_POST['crystals'];
if($_POST['crystals'] <= 0 || $_POST['crystals'] > $ir['crystals'])
{
print "Error, you either do not have enough Credits or did not fill out the form.

[url='crystaltemple.php?spend=money']Back[/url]";
}
else
{
$iqgain=$_POST['crystals']*$set['ct_moneypercrys'];
$db->query("UPDATE users SET crystals=crystals-{$_POST['crystals']},money=money+$iqgain WHERE userid=$userid");
print "You traded {$_POST['crystals']} Credits for \$".number_format($iqgain).".";
}
}
}

$h->endpage();
?>

 

Below is what I have attempted to do, though has not worked for me. [Not in the script above]

}
else if($_GET['spend'] == 'points')
{
print "<HR width='75%'>Type in the amount of cash you would like to trade for points, 1 point = $1000.<HR width='75%'>
<form action='tradingbooth.php?spend=points2' method='post'><input type='text' name='money' />
<input type='submit' value='Trade' /></form>";
}
else if($_GET['spend'] == 'points2')
{
$_POST['money']=(int) $_POST['money'];
if($_POST['money'] <= 1000 || $_POST['money'] > $ir['money'])
{
print "Error, you either do not have enough money or did not fill out the form.

[url='tradingbooth.php?spend=points']Back[/url]";
}
else
{
$iqgain=$_POST['money']/1000;
$db->query("UPDATE users SET crystals=crystals+$iqgain,money=money-{$_POST['money']} WHERE userid=$userid");
print "You traded {$_POST['crystals']} Credits for \$".number_format($iqgain).".";
}
Link to comment
Share on other sites

Re: Point/Cash Exchange

 

what is it doing? whats the error...would help.....make it faster to help you....dont want to recode you a whole page lol

In crystaltemple.php you are able to sell points for cash, though I wish for the user also to be able to buy points using cash.

Link to comment
Share on other sites

Re: Point/Cash Exchange

Not exactly certain but if your trying to give a user Points is this called under crystals in the database?

$db->query("UPDATE users SET crystals=crystals+$iqgain,money=money-{$_POST['money']} WHERE userid=$userid");
print "You traded {$_POST['crystals']} Credits for \$".number_format($iqgain).".";

Because or that would need to be edited.

to something lke

$_POST['money'] = abs(@intval($_POST['money']));
$sql = sprintf("UPDATE users SET points=points+%s,money=money-{%s} WHERE userid=%s, $iqgain, $_POST['money'], $userid);
$db->query($sql);
print "You traded {$_POST['crystals']} Credits for \$".number_format($iqgain).".";

Im not entirely sure tho (BTW i added security to the second one ;))

Can you explain what the problem is more?

Link to comment
Share on other sites

Re: Point/Cash Exchange

I see no error....posted..

i see your code....and you saying its not working..

What is not working?

Im not uploading this to my game to see what is not working or what error is coming out..

POST THE ERROR

OR SAY WHATS NOT WORKING

or post in mod request... to request someone to make this for you..this is the help section

its Impossible to help you if you way here is some code...it dont work

please help.

 

how do i know what to fix

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...