Commit d9950634 authored by Gaetan Carabetta's avatar Gaetan Carabetta

update code

parent 56c1d002
......@@ -7,9 +7,9 @@
<?php
$vHost = 'tuxa.sme.utc';
$vPort = '5432';
$vData = 'dbbdd0p117';
$vUser = 'bdd0p117';
$vPass = 'LpIHl1sZ';
$vData = 'dbbdd0p042';
$vUser = 'bdd0p042';
$vPass = 'cyLu9JFl';
try{
$vConn = new PDO("pgsql:host=$vHost;port=$vPort;dbname=$vData", $vUser, $vPass);
......@@ -35,7 +35,7 @@
$vSt = $vConn->prepare($vSql);
$vSt->execute();
header('Location: http://tuxa.sme.utc/~bdd0p117/animal.php');
header('Location: http://tuxa.sme.utc/~bdd0p042/application/animal.php');
}else
echo "Il faut donner une espece";
}else
......
<p> Test </p>
<p> <?php echo $_POST['affiche']; ?> </p>
<?php
if ($_POST['ajoute'] == "clients"){
include("ajoutClient.php");
} elseif ($_POST['ajoute'] == "animaux"){
include("ajoutAnimal.php");
} elseif ($_POST['ajoute'] == "traitements"){
include("ajoutTraitement.php");
} else {
include("error.php");
}
?>
<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>
......@@ -22,9 +22,9 @@
// Connexion à la base de données
$vHost = 'tuxa.sme.utc';
$vPort = '5432';
$vData = 'dbbdd0p117';
$vUser = 'bdd0p117';
$vPass = 'LpIHl1sZ';
$vData = 'dbbdd0p042';
$vUser = 'bdd0p042';
$vPass = 'cyLu9JFl';
try{
$vConn = new PDO("pgsql:host=$vHost;port=$vPort;dbname=$vData", $vUser, $vPass);
......@@ -33,12 +33,16 @@
}
// Affichage du tableau de données
$vSql ='select * from Animal;';
if ($_POST['affiche'] == "animaux")
$vSql ='select * from Animal;';
include("animal.php");
try{
$vSt = $vConn->prepare($vSql);
$vSt->execute();
while ($vResult = $vSt->fetch(PDO::FETCH_BOTH)) {
echo '<tr>';
echo "<td>$vResult[0]</td>";
......
<?php
$vHost = 'tuxa.sme.utc';
$vPort = '5432';
$vData = 'dbbdd0p042';
$vUser = 'bdd0p042';
$vPass = 'cyLu9JFl';
?>
<p> Choix non supporté, veuillez retourner à l'index </p>
......@@ -10,7 +10,7 @@
<form method="post" action="affichage.php">
<p>
<label> Affiche la/les table(s) </label><br />
<select>
<select name="affiche">
<option value="all" selected>All</option>
<option value="clients">Clients</option>
<option value="veterinaires">Veterinaires</option>
......@@ -30,7 +30,7 @@
<form method="post" action="ajout.php">
<p>
<label> Ajout à la table </label><br />
<select>
<select name="ajoute">
<option value="clients" selected>Clients</option>
<option value="animaux">Animaux</option>
<option value="traitements">Traitements</option>
......
......@@ -5,11 +5,12 @@
</head>
<body>
<?php
$vHost = 'tuxa.sme.utc';
/*$vHost = 'tuxa.sme.utc';
$vPort = '5432';
$vData = 'dbbdd0p117';
$vUser = 'bdd0p117';
$vPass = 'LpIHl1sZ';
$vPass = 'LpIHl1sZ';*/
include("connexion.php");
try{
$vConn = new PDO("pgsql:host=$vHost;port=$vPort;dbname=$vData", $vUser, $vPass);
......@@ -33,7 +34,7 @@
$vSt = $vConn->prepare($vSql);
$vSt->execute();
header('Location: http://tuxa.sme.utc/~bdd0p117/animal.php');
header('Location: http://tuxa.sme.utc/~bdd0p042/application/animal.php');
}else
echo "Il manque une donnée";
} catch(PDOException $e){
......
......@@ -6,11 +6,13 @@
</head>
<body>
<?php
$vHost = 'tuxa.sme.utc';
/*$vHost = 'tuxa.sme.utc';
$vPort = '5432';
$vData = 'dbbdd0p117';
$vUser = 'bdd0p117';
$vPass = 'LpIHl1sZ';
*/
include("connexion.php");
try{
$vConn = new PDO("pgsql:host=$vHost;port=$vPort;dbname=$vData", $vUser, $vPass);
} catch(PDOException $e){
......@@ -20,7 +22,7 @@
if($idAnimal == ""){
echo "Il faut dire quel animal";
header('Location: http://tuxa.sme.utc/~bdd0p117/animal.php');
header('Location: http://tuxa.sme.utc/~bdd0p042/application/animal.php');
}
?>
......
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