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

$voyage = $_POST["verif1"];
$date = $_POST["verif2"];
$iddepart = $_POST["verif3"];
$iddestination = $_POST["verif4"];
$mission = $_POST["verif5"];

$sql = "SELECT idjoueur FROM matgraph_users WHERE id='$iddepart' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$row = mysql_fetch_array($res);
 
$datetime = $date;

ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetime, $thetime);
$time = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);

$diftemps = time() - $time;
$newDate =  strftime("%Y-%m-%d %H:%M:%S", time()+ (round($voyage+$diftemps)));

if ($row[idjoueur] == $idlogin) {
	$sql = "UPDATE matgraph_mobil SET mission='retour', date = '$newDate' WHERE mission!='retour' AND voyage='$voyage' AND date='$date' AND iddepart='$iddepart' AND iddestination='$iddestination'";
	$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

echo '<script language="javascript" type="text/javascript">
<!--
window.location.replace("apercu.php");
-->
</script>';

?>