Mark F Posted September 7, 2008 Share Posted September 7, 2008 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)."."; } Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted September 9, 2008 Share Posted September 9, 2008 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 Quote Link to comment Share on other sites More sharing options...
Mark F Posted September 9, 2008 Author Share Posted September 9, 2008 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. Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted September 9, 2008 Share Posted September 9, 2008 Re: Point/Cash Exchange I'm not going to code it for you............ you said you have coded it...and its NOT working.... Post Your error... Quote Link to comment Share on other sites More sharing options...
Dave Posted September 9, 2008 Share Posted September 9, 2008 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? Quote Link to comment Share on other sites More sharing options...
Mark F Posted September 11, 2008 Author Share Posted September 11, 2008 Re: Point/Cash Exchange I'm not going to code it for you............ you said you have coded it...and its NOT working.... Post Your error... I posted the part that I attempted in my first post, the second section of code. Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted September 13, 2008 Share Posted September 13, 2008 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.