ajoutAnimal.php 1.63 KB
Newer Older
Gaetan Carabetta's avatar
Gaetan Carabetta committed
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 51 52
<html>
<head>
  <title>Exercice</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" type="text/css" href="style.css">
  </head>
<body>
  <h1>Information des animaux</h1>
  <?php
  // Connexion à la base de données
    $vHost = 'tuxa.sme.utc';
    $vPort = '5432';
    $vData = 'dbbdd0p042';
    $vUser = 'bdd0p042';
    $vPass = 'cyLu9JFl';
    $vConn = new PDO("pgsql:host=$vHost;port=$vPort;dbname=$vData", $vUser, $vPass);
  ?>
  <div>
    <form  action="addAnimal.php" method="post">
       <p>Nom de l'animal: <input type="text" name="nom" required/></p>
       <p>Poids: <input type="text" name="poids" required/></p>
       <p>Taille: <input type="text" name="taille" required/></p>
       <p>Date de naissance: <input type="date" name="ddn" required/></p>
       <p>Client:
         <select name="client" required/>
         <?php
             $vSql ='select idClient from Client;';
             $vSt = $vConn->prepare($vSql);
             $vSt->execute();
             while ($vResult = $vSt->fetch(PDO::FETCH_BOTH)) {
               echo "<option>$vResult[0]</option>";
             }
         ?>
        </select>
       </p>
       <p>Espece:
           <select name="espece" required/>
           <?php
               $vSql ='select nomEspece from Espece;';
               $vSt = $vConn->prepare($vSql);
               $vSt->execute();
               while ($vResult = $vSt->fetch(PDO::FETCH_BOTH)) {
                 echo "<option>$vResult[0]</option>";
               }
           ?>
          </select>
       </p>
       <p><input type="submit" value="OK"></p>
    </form>
  </div>
</body>
</html>