Commit 3213e039 authored by Gaetan Carabetta's avatar Gaetan Carabetta

Update requests

parents 58ff17e4 d72c355d
<html>
<head>
<title>Clinique Vétérinaire</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Ajout d'un Traitement</h1>
<?php
// Connexion à la base de données
include("connexion.php");
$vConn = new PDO("pgsql:host=$vHost;port=$vPort;dbname=$vData", $vUser, $vPass);
?>
<div>
<form action="addTraitement.php" method="post">
<p>Animal:
<select name="animal" required/>
<?php
$vSql ='select idAnimal from Animal;';
$vSt = $vConn->prepare($vSql);
$vSt->execute();
while ($vResult = $vSt->fetch(PDO::FETCH_BOTH)) {
echo "<option>$vResult[0]</option>";
}
?>
</select>
</p>
<p>ID Vétérinaire:
<select name="veterinaire" required/>
<?php
$vSql ='select idVeterinaire from Veterinaire;';
$vSt = $vConn->prepare($vSql);
$vSt->execute();
while ($vResult = $vSt->fetch(PDO::FETCH_BOTH)) {
echo "<option>$vResult[0]</option>";
}
?>
</select>
</p>
<p>Médicament:
<select name="medicament" required/>
<?php
$vSql ='select nomMolec from Medicament;';
$vSt = $vConn->prepare($vSql);
$vSt->execute();
while ($vResult = $vSt->fetch(PDO::FETCH_BOTH)) {
echo "<option>$vResult[0]</option>";
}
?>
</select>
</p>
<p>Date de debut: <input type="date" name="ddebut" required/></p>
<p>Durée: <input type="number" name="duree" required/></p>
<p>Quantité par jour: <input type="number" name="qteJour" required/></p>
<p><input type="submit" value="OK"></p>
</form>
</div>
</body>
</html>
<html>
<head>
<title>Clinique Vétérinaire</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php
include("connexion.php");
try{
$vConn = new PDO("pgsql:host=$vHost;port=$vPort;dbname=$vData", $vUser, $vPass);
} catch(PDOException $e){
echo "Erreur de connexion '$e'";
}
try{
$idAnimal = $_POST['animal'];
$idVeterinaire = $_POST['veterinaire'];
$medicament = $_POST['medicament'];
$date = $_POST['ddebut'];
$duree = $_POST['duree'];
$qte = $_POST['qteJour'];
if($qteJour!=""){
if($idAnimal != ""){
if($idVeterinaire != ""){
if($medicament != ""){
if($date != ""){
if($duree != ""){
$vSql ="INSERT INTO TRAITEMENT (idAnimal,idVeterinaire) VALUES ('$idAnimal','$idVeterinaire');";
$vSt = $vConn->prepare($vSql);
$vSt->execute();
$vSql ="INSERT INTO POSOLOGIE (idTraitement,nomMolec,debut,duree,nbJourna) VALUES ((SELECT idTraitement WHERE idAnimal='$idAnimal' AND idVeterinaire='$idVeterinaire'),'$medicament','$date','$duree','$qte');";
$vSt = $vConn->prepare($vSql);
$vSt->execute();
header('Location: http://tuxa.sme.utc/~bdd0p042/application/animaux.php');
}else
echo "Il faut donner une durée";
}else
echo "Il faut donner une date";
}else
echo "Il faut donner un médicament";
}else
echo "Il faut donner un vétérinaire";
}else
echo "Il faut donner un animal";
}else{
echo "Il faut donner la quantité"
}
} catch(PDOException $e){
echo "Erreur d'insertion '$e'";
}
?>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment