<? include('checkcookie.php'); ?>
<h3>Запросы на пополнение баланса</h3>
<br>

<?
if ($_GET["option"]=="success")
{
	$amount=$_POST["amount"];
	$user=$_POST["username"];
	$id=$_POST["id"];

	$sql="update tb_users set money=money+'$amount' where username='$user'";
	mysql_query($sql);

	mysql_query("delete from tb_mta where id='$id'");

	echo "Готово";
}

if ($_GET["option"]=="cancel")
{
	$id=$_POST["id"];	

	$sql="delete from tb_mta where id='$id'";
	mysql_query($sql);

	echo "Удалено";
}
?>

<table  width="100%" cellspacing="0" cellpadding="0">
<tr>
<th>Пользователь</th>
<th>Сумма пополнения</th>
<th></th><th></th>
</tr>
<?
$sql="select * from tb_mta order by id asc";
$res=mysql_query($sql);

if (mysql_num_rows($res)>0)
{
	while ($row=mysql_fetch_assoc($res))
	{
		?><tr><td><?
		echo $row["user"];
		?></td><td><?
		echo $row["amount"];
		?></td>
		<td>
		<form method="post" action="adminmain.php?p=reqmta&option=success">
		<input type="hidden" name="username" value="<?= $row["user"] ?>">
		<input type="hidden" name="amount" value="<?= $row["amount"] ?>">
		<input type="hidden" name="id" value="<?= $row["id"] ?>">
		<input type="submit" value="Подтвердить" class="button">
		</form>
		</td>
		<td>
		<form method="post" action="adminmain.php?p=reqmta&option=cancel">
		<input type="hidden" name="id" value="<?= $row["id"] ?>">
		<input type="submit" value="Удалить" class="button">
		</form>
		</td>
		</tr>
		<?
	}
}
?>
</table>