Jump to content

$_POST


grant09

Recommended Posts

ok am workin on this script its a points market for a text based game but my money is not taking the amount of the players i points on the market ... just say i post 10 points for $29.000.000 ... and when the player  buys the points it takes the money from that user and give the user points but .... when the user buy the points it dont give the user the money it give $290 ?? not sure is its my SQL av post that to

 

 

<?php
include 'header.php';

$_POST['buypoints'] =  abs(intval($_POST['buypoints']));{


$result = mysql_query("SELECT * FROM `pointsmarket` WHERE `id`='".$_POST['points_id']."'");
    $worked = mysql_fetch_array($result);
    $price = $worked['price'];
    $amount = $worked['amount'];
	$totalcost = $price * prettynum($_POST['amount']);
	$newpointsinmarket = $amount - prettynum($_POST['amount']);
	$user_points = new User($worked['owner']);

if ($worked['owner'] == $user_class->id) {
	echo Message("You have taken ".$_POST['amount']." points off the market.");
	$newpoints = $user_class->points + $_POST['amount'];;
	$result = mysql_query("UPDATE `grpgusers` SET `points` = '".$newpoints."' WHERE `id`='".$user_class->id."'");
	$user_class = new User($_SESSION['id']);
		if ($newpointsinmarket == 0){
			$result = mysql_query("DELETE FROM `pointsmarket` WHERE `id`='".$worked['id']."'");
		} else {
			$result = mysql_query("UPDATE `pointsmarket` SET `amount` = '".$newpointsinmarket."' WHERE `id`='".$worked['id']."'");
	}
include 'footer.php';
die();
}
	$_POST['amount'] =  abs(intval($_POST['amount']));
$_POST['points_id'] = abs(intval($_POST['points_id']));{

}
$_POST['amount'] =  abs(intval($_POST['amount']));
$_POST['points_id'] = abs(intval($_POST['points_id']));{

}
if ($totalcost > prettynum($user_class->money)){
	echo Message("You don't have enough money.");
}
if($_POST['amount'] >= 1 && $_POST['amount'] <= $amount && $totalcost <= $user_class->money){
	echo Message("You have bought ".$_POST['amount']." points for $".$totalcost);
	$newpoints = $user_class->points + $_POST['amount'];
	$newmoney = $user_class->money - $totalcost;
	$result = mysql_query("UPDATE `grpgusers` SET `money` = '".$newmoney."', `points` = '".$newpoints."' WHERE `id`='".$user_class->id."'");
	$newmoney = $user_points->money + $totalcost;
	$result = mysql_query("UPDATE `grpgusers` SET `money` = '".$newmoney."' WHERE `id`='".$user_points->id."'");
	$user_class = new User($_SESSION['id']);
		if ($newpointsinmarket == 0){
			$result = mysql_query("DELETE FROM `pointsmarket` WHERE `id`='".$worked['id']."'");
		} else {
			$result = mysql_query("UPDATE `pointsmarket` SET `amount` = '".$newpointsinmarket."' WHERE `id`='".$worked['id']."'");
		}
}
}

$_POST['addpoints'] =  abs(intval($_POST['addpoints']));
$_POST['id'] = abs(intval($_POST['id']));{

}
if($_POST['amount'] < 1){

}
if($_POST['price'] < 1){

}
if ($_POST['amount'] >= 1 && prettynum($_POST['amount']) <= $user_class->points && $_POST['price'] >= 1){
	echo Message("You have added ".$_POST['amount']." points to the market a price of $".$_POST['price']." per point.");
	$result= mysql_query("INSERT INTO `pointsmarket` (owner, amount, price)"."VALUES ('$user_class->id', '$_POST[amount]', '$_POST[price]')");
	$newpoints = $user_class->points - $_POST['amount'];
	$result = mysql_query("UPDATE `grpgusers` SET `points` = '".$newpoints."' WHERE `id`='".$user_class->id."'");
	$user_class = new User($_SESSION['id']);
}

?>
<link href="style.css" rel="stylesheet" type="text/css" />

<tr><td class="contenthead">Point Market</td></tr>
<tr><td align="center" class="contentcontent">
<p> </p>
<p><strong>You need to be a Respected Warrior to add points to the market</strong><br>
Use this form to add points to the points market.</p>
<p><strong>Bank Account[<? echo prettynum($user_class->bank) ?>]</strong><strong></strong><br /> 
  <strong><a href="pointmarket.php">[Refresh</a>]</strong></p>
<form method='post'>
  <table align="center">
  <tr>
<td>Amount of points</td><td>  <input name='amount' type='text' class="areatest" value='0' size='10' maxlength='20'></td>
</tr>
<tr>
<td>Price per point</td><td>$<input name='price' type='text' class="areatest" value="0" size='10' maxlength='20'></td>
<tr><td align="center" colspan="2"><input name='addpoints' type='submit' class="buttong" value='Add Points'></form></td>
</tr></table>
</td></tr>
<tr><td class="contentcontent">
<?php
$result = mysql_query("SELECT * FROM `pointsmarket` ORDER BY `price` DESC");
while($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$user_points = new User($line['owner']);
if ($user_points->id == $user_class->id){
	$submittext = "Remove";
} else {
	$submittext = "Buy";
}
echo "<form method='post'>";
echo $user_points->formattedname." - ".$line['amount']." points for ".prettynum($line['price'],1)." per point <input type='text' name='amount' size='3' maxlength='20' value='".prettynum($line['amount'])."'><input type='hidden' name='points_id' value='".$line['id']."'><input type='submit' name='buypoints' value='".$submittext."'></form><br>";
}
?>
</td></tr>
<?php
include 'footer.php';
?>

 

 

SQL

CREATE TABLE IF NOT EXISTS `pointsmarket` (
  `owner` int(10) NOT NULL default '0',
  `amount` text NOT NULL,
  `price` text NOT NULL,
  `id` int(10) NOT NULL auto_increment,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=81 ;

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

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