You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PROJET-WEB_STRI1A/WEB/voiture/fonctionsVoiture.php

64 lines
2.0 KiB
PHTML

<?php
/*require ('../connectionBD.php');
$mail = null;
$db = connexionBD();
init();
*/
$matricule = $_POST['matricule'];
$marque = $_POST['marque'];
$modele = $_POST['modele'];
$nbplaces = $_POST['nbplaces'];
$anneefab = $_POST['anneefab'];
if(isset($_POST['submitadd']))
{
addVoiture($matricule, $marque, $modele, $nbplaces, $anneefab);
}
if(isset($_POST['submitchange']))
{
changeVoiture($matricule, $marque, $modele, $nbplaces, $anneefab);
}
if(isset($_POST['submitshow']))
{
showVoiture();
}
function init(){
session_start();
global $mail;
//Si on est pas connecté redirection vers la page de connexion
if(!isset($_SESSION['mail'])){
header('Location: ../index.php');
exit();
}
else{
$mail = $_SESSION['mail'];
}
}
function addVoiture($matricule, $marque, $modele, $nbplaces, $anneefab){
//global $db;
$requete = "INSERT INTO public.voiture (matricule, marque, modele, nbplaces, anneefab, mail) VALUES ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."','mail');";
//$requete = "INSERT INTO 'public'.'voiture' ('matricule','marque','modele','nbplaces','anneefab','mail') VALUES ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."','".$_SESSION['mail']."');";
echo "requete =".$requete;
//pg_query($db, $requete);
}
function changeVoiture($matricule, $marque, $modele, $nbplaces, $anneefab){
//global $db;
$requete = "UPDATE public.voiture SET (matricule, marque, modele, nbplaces, anneefab) = ('".$matricule."','".$marque."','".$modele."','".$nbplaces."','".$anneefab."') WHERE mail = '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);
}
function showVoiture(){
//global $db;
$requete = "SELECT * FROM voiture WHERE voiture.mail = '".$_SESSION['mail']."';";
echo "requete =".$requete;
//pg_query($db, $requete);
}
?>