PHP Code:
<?php
function update_boni($id, $boni, $expire, $coins)
{
$sql="update account set ".$boni." = '$expire', coins = '$coins' where id='$id'";
$answer=mysql_query($sql) or die("fehler");
return;
}
$id = $_SESSION["user_id"];
$sql = "SELECT * FROM account.account WHERE id = $id ";
$ergebnis=mysql_query($sql);
$ergebnis1=mysql_fetch_array($ergebnis);
$coins =$ergebnis1['coins'];
if (isset($_POST['submit']))
{
$boni=$_POST['boni'];
$coins1=$_POST['cost'];
$tage1=$_POST['tage'];
$desc=$_POST['desc'];
if ($coins < $coins1)
{
echo "Tut uns leid aber sie haben zu wenig Coins";
echo "<meta http-equiv='refresh' content='3, url=index.php?site=sys/ishop/is&s=server_boni'>";
}
else
{
echo "<H3>Kaufbestätigung</H3><hr>";
echo "Du hast dir ".$tage1." ".$desc." zum preis von ".$coins1." Coins gekauft<br>";
echo "die ".$coins1." Coins werden dir von deinen ".$coins." Coins abgezogen<br>";
$date_expire=$ergebnis1[$boni];
$coins=$coins-$coins1;
echo "Du hast jetzt noch ".$coins." übrig<br>";
if ($date_expire == "0000-00-00 00:00:00")
{
datum_heute();
add_days($now, $tage1);
update_boni($id,$boni,$newdate,$coins);
}
else
{
add_days($date_expire, $tage1);
update_boni($id,$boni,$newdate,$coins);
}
}
}
unset($_POST);
echo "<meta http-equiv='refresh' content='3, url=index.php?site=sys/ishop/is&s=server_boni'>";
?>