1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| <?php
// Récupération des données
$nom_ajout1=$_GET['nom1'];
$prenom_ajout1=$_GET['prenom1'];
$sexe1=$_GET['sexe'];
$date_naissance_ajout1=$_GET['naissance1'];
$situation=$_GET['situation'];
$uid=uniqid();
$nom_ajout2=$_GET['nom2'];
$prenom_ajout2=$_GET['prenom2'];
$sexe2=$_GET['s2'];
$date_naissance_ajout2=$_GET['naissance2'];
// $nb_enfants=$_GET['enfants1'];
// 2:Requête en fonction de la situation
if ($situation == 'Célibataire')
{
// 1:Requête en fonction du sexe
if ($sexe == 'M1')
{
$req="INSERT INTO t_h (nom, prenom, date_naissance, id, situation) VALUES ('".$nom_ajout1."', '".$prenom_ajout1."', '".$date_naissance_ajout1."', '".$uid."', '".$situation."')";
}
else
{
$req="INSERT INTO t_f (nom, prenom, date_naissance, id, situation) VALUES ('".$nom_ajout1."', '".$prenom_ajout1."', '".$date_naissance_ajout1."', '".$uid."', '".$situation."')";
}
}
else
{
if ($sexe1 == 'M1')
{
$req="INSERT INTO t_h (nom, prenom, date_naissance, id, situation) VALUES ('".$nom_ajout1."', '".$prenom_ajout1."', '".$date_naissance_ajout1."', '".$uid."', '".$situation."')";
}
else
{
$req="INSERT INTO t_f (nom, prenom, date_naissance, id, situation) VALUES ('".$nom_ajout1."', '".$prenom_ajout1."', '".$date_naissance_ajout1."', '".$uid."', '".$situation."')";
}
if ($sexe2 == 'M2')
{
$req="INSERT INTO t_h (nom, prenom, date_naissance, id, situation) VALUES ('".$nom_ajout2."', '".$prenom_ajout2."', '".$date_naissance_ajout2."', '".$uid."', '".$situation."')";
}
else
{
$req="INSERT INTO t_f (nom, prenom, date_naissance, id, situation) VALUES ('".$nom_ajout2."', '".$prenom_ajout2."', '".$date_naissance_ajout2."', '".$uid."', '".$situation."')";
}
}
// Execution de la requête SQL
$res_ajout = pg_query($req) or die('Échec de la requête : ' . pg_last_error());
// Ferme la connexion
pg_close($dbconn);
?> |