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 53 54 55 56 57 58 59 60 61
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Document sans titre</title>
</head>
<body>
<?php
require("params.inc.php");
mysql_connect($hote, $login, $mdp); // Connexion à MySQL
mysql_select_db($bd); // Sélection de la base
//etape1: on insere les valeurs dans la table recette
$ptitle = $_POST['title'];
$pdescription = $_POST['description'];
$pyld = $_POST['yld'];
$ptime = $_POST['ptime'];
$pctime = $_POST['ctime'];
$pttime = $_POST['ttime'];
$pcuisine = $_POST['cuisine'];
$pconvenience = $_POST['convenience'];
$poccasion = $_POST['occasion'];
$pcourse = $_POST['course'];
mysql_query("INSERT INTO recette VALUES('','$ptitle','$pdescription','$pyld','','','','','','','')") or die('Erreur SQL !<br>'.mysql_error());
//on recup l'id de la recette
$id_recette=mysql_insert_id();
//etape2:on insere les valeures dans la table nutrients
mysql_query("INSERT INTO nutrients VALUES('','$id_recette','$pcalories','$ptotalfat','','','','','')") or die('Erreur SQL !<br>'.mysql_error());
$pcalories = $_POST['calories'];
$ptotalfat = $_POST['totalfat'];
//etape3:on insere les donnees dans la table ingredients.
for(i=1;isset($_REQUEST['ingredient_'.i]);i++)
{
$pingredient1_.i = $_POST['ingredient1_'.i];
$pingredient2_.i = $_POST['ingredient2_'.i];
$pingredient3_.i = $_POST['ingredient3_'.i];
echo $pingredients1_i;
mysql_query("INSERT INTO ingredients VALUES('','$id_recette','$pingredient1_','$pingredient2_','$pingredient3_')") or die('Erreur SQL !<br>'.mysql_error());
}
mysql_close(); // Déconnexion de MySQL
?>
</body>
</html> |