<?	
include ('logue.php'); 
include ('entete2.php');

$id = htmlentities ($_POST["id"]);
$idplanete = htmlentities ($_POST["planete"]);
$idjoueur = htmlentities ($_POST["envoyeur"]);
$type = htmlentities ($_POST["type"]);

$requete = "INSERT INTO matgraph_commerce VALUES ('', '$type', '$idjoueur', '$idlogin')";
$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());

$requete = "INSERT INTO matgraph_commerce VALUES ('', '$type', '$idlogin', '$idjoueur')";
$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());

$sql4 = "SELECT mili_nbre FROM matgraph_users WHERE id=$idplanete";
$res4 = db_mysql_Query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
$row4 = mysql_fetch_array($res4);   
$mili_nbre = $row4[mili_nbre] + 100 ;
$requete = "UPDATE matgraph_users SET mili_nbre=$mili_nbre WHERE id='$idplanete'";
$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());

$sujet = "Proposition de pacte $type accepté.";
$msg = "Votre proposition de pacte $type a bien été accepter par $login";
$requete = "INSERT INTO matgraph_msg VALUES ('', now(), 'non', '$idjoueur', '$sujet', '$msg')";
$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());

$sql4 = "DELETE FROM matgraph_explorer WHERE id = '$id'";
$res4 = db_mysql_Query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
echo '<script language="javascript" type="text/javascript">
<!--
window.location.replace("commerce.php");
-->
</script>';
  
?>