//Si on est pas connecté redirection vers la page de connexion
if(!isset($_SESSION['mail'])){
header('Location: ../index.php');
exit();
}
else{
$mail=$_SESSION['mail'];
}
}
functiongetPrenom($mail){
global$db;
$result=pg_query_params($db,"SELECT prenom from Utilisateur WHERE mail = $1;",array($mail));
if($result){
$row=pg_fetch_array($result);
$prenom=$row[0];
return$prenom;
}
returnnull;
}
functiongetLogin($mail){
global$db;
$result=pg_query_params($db,"SELECT login from Utilisateur WHERE mail = $1;",array($mail));
if($result){
$row=pg_fetch_array($result);
$login=$row[0];
return$login;
}
returnnull;
}
functiongetTrajetsProposes($mail){
global$db;
$result=pg_query_params($db,"SELECT COUNT(*) from Trajet WHERE mailProposition = $1 AND estAnnule = false AND datedepart >= current_date;",array($mail));
if($result){
$row=pg_fetch_array($result);
return$row[0];
}
return0;
}
functiongetTrajetsReserves($mail){
global$db;
$result=pg_query_params($db,"SELECT COUNT(*) FROM trajet tr, reserver r WHERE r.codetrajet = tr.codetrajet AND mailutilisateur = $1 AND etatres != 'Annulée' AND estAnnule = false AND datedepart >= current_date;",array($mail));
if($result){
$row=pg_fetch_array($result);
return$row[0];
}
return0;
}
functiongetMessagesNonLus($mail){
global$db;
$result=pg_query_params($db,"SELECT COUNT(*) from Message WHERE mailRecepteur = $1 AND estLu = FALSE;",array($mail));
if($result){
$row=pg_fetch_array($result);
$login=$row[0];
return$login;
}
}
functiongetAvisNonLus($mail){
global$db;
$result=pg_query_params($db,"SELECT COUNT(tr.mailProposition) FROM Trajet tr, Avis av WHERE tr.codeTrajet = av.codeTrajet AND av.estLu = false AND tr.mailProposition = $1;",array($mail));
$requete="UPDATE public.voiture SET (matricule, marque, modele, nbplaces, anneefab) = ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."') WHERE mail = '".$_SESSION['mail']."';";
echo"requete =".$requete;
pg_query($db,$requete);
}
functionshowVoiture(){
global$db;
$requete="SELECT * FROM public.voiture WHERE voiture.mail = '".$_SESSION['mail']."';";
if($donnees=pg_query($db,$requete)){
while($res=pg_fetch_assoc($donnees)){
echo"matricule = ".$res['matricule']."<br>";
echo"marque = ".$res['marque']."<br>";
echo"modele = ".$res['modele']."<br>";
echo"nombre de places = ".$res['nbplaces']."<br>";
echo"année de fabrication = ".$res['anneefab']."<br>";