addClient.php 1.51 KB
Newer Older
Gaetan Carabetta's avatar
Gaetan Carabetta committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Clinique Vétérinaire</title>	
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <?php
      include("connexion.php");

      $nom = $_POST['nom'];
      $prenom = $_POST['prenom'];
      $ddn = $_POST['ddn'];
Gaetan Carabetta's avatar
Gaetan Carabetta committed
15
      $adress = $_POST['adresse'];
Gaetan Carabetta's avatar
Gaetan Carabetta committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
      $ntel = $_POST['ntel'];

      try
      {
        $vConn = new PDO("pgsql:host=$vHost;port=$vPort;dbname=$vData", $vUser, $vPass);
      } catch(PDOException $e)
      {
        echo "Erreur de la connexion '$e'";
      }

        if($nom != "")
        {
          if ($prenom != "")
          {
            if ($ddn != "")
            {
Gaetan Carabetta's avatar
Gaetan Carabetta committed
32
              if ($adress != "")
Gaetan Carabetta's avatar
Gaetan Carabetta committed
33 34 35 36
              {
                if ($ntel != "")
                {

Gaetan Carabetta's avatar
Gaetan Carabetta committed
37
			$vSql ="INSERT INTO Client (nom,prenom,ddn,adresse,numero) VALUES ( '$nom','$prenom','$ddn','$adress','$ntel');";   
Gaetan Carabetta's avatar
Gaetan Carabetta committed
38 39 40 41
			try
			{
        $vSt = $vConn->prepare($vSql);
				$vSt->execute();
Gaetan Carabetta's avatar
Gaetan Carabetta committed
42 43

        header('Location: http://tuxa.sme.utc/~bdd0p042/application/clients.php');
Gaetan Carabetta's avatar
Gaetan Carabetta committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
			} 
			catch(PDOException $e)
			{
				echo "Erreur en l'insertion '$e'";
			}
                }
              }
              else
               echo "Il faut de donner le numero de telephone";
            }
            else
             echo "Il faut de donner l'addresse";
          }
          else
           echo "Il faut de donner le prenom";
        }
        else
         echo "Il faut de donner le nom";
       ?>
    </table>

  </body>
</html>