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

    try{
      $vConn = new PDO("pgsql:host=$vHost;port=$vPort;dbname=$vData", $vUser, $vPass);
    } catch(PDOException $e){
Gaetan Carabetta's avatar
Gaetan Carabetta committed
13
      echo "Erreur de connexion '$e'";
Osvaldo Valdivia Salas's avatar
Osvaldo Valdivia Salas committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
    }

    try{
        $nom = $_POST['nom'];
        $poids = $_POST['poids'];
        $taille = $_POST['taille'];
        $ddn = $_POST['ddn'];
        $client = $_POST['client'];
        $espece = $_POST['espece'];

        if($nom != ""){
          if($poids != ""){
              if($taille != ""){
                if($client != ""){
                    if($espece != ""){

                        $vSql ="INSERT INTO ANIMAL (nom,poids,taille,naissance,idClient,especeNom) VALUES ('$nom','$poids','$taille','$ddn','$client','$espece');";
                        $vSt = $vConn->prepare($vSql);
                        $vSt->execute();

Gaetan Carabetta's avatar
Gaetan Carabetta committed
34
                        header('Location: http://tuxa.sme.utc/~bdd0p042/application/animaux.php');
Osvaldo Valdivia Salas's avatar
Osvaldo Valdivia Salas committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
                    }else
                      echo "Il faut donner une espece";
                }else
                  echo "Il faut donner un client";
              }else
                echo "Il faut donner une taille";
          }else
            echo "Il faut donner un poids";
        }else
          echo "Il faut donner un nom";
    } catch(PDOException $e){
      echo "Erreur d'insertion '$e'";
    }
  ?>
</body>
</html>