<?php
include ( 'check.php' );

include ( '../inc/settings.php' );

$id=escape ( $_GET['id'] ); 

mysql_select_db ( 'shop' );

$query=mysql_query("SELECT * FROM shop_log WHERE id='$id'");

if ( $query ) {

$f=mysql_fetch_array($query);

if ( $f['status']=="PAGATO" ) {

echo "Hai già Ricevuto Le monete.";

}

if ( $f['status']=="pending" ) {

echo "Hai già Ricevuto Le monete. L' acquisto non è stato ancora confermato.";

}

if ( $f['status']=="ok" ) {
$query2=mysql_query("SELECT * FROM shop WHERE id='$f[shopitem_id]'");

if ( $query2 ) {
$f2=mysql_fetch_array($query2);
$monete = $f2 ['monete'];

echo "Ciao $user, hai acquistato $f2[nome], al prezzo di $f[prezzo]&euro;<br>";
echo "Ti sono state Accreditate : $monete Monete";

mysql_select_db ( 'account' );
$query_1 = mysql_query ( "SELECT * FROM account WHERE login='$user'" );
$check = mysql_fetch_array($query_1);
$attuali = $check ['monete'];
$totali = ($attuali + $monete);
$query_add = mysql_query ( "UPDATE account SET monete='$totali' WHERE login='$user'" );

mysql_select_db ( 'shop' );
$query_adds = mysql_query ( "UPDATE shop_log SET status='PAGATO' WHERE id='$id'" );

session_start ( );
session_unset ( );
session_destroy ( );

}

}

}
?>