Advertisement
Guest User

Untitled

a guest
May 25th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.27 KB | None | 0 0
  1. <!Doctype html>
  2.  
  3.  
  4.    <html>
  5.     <head>
  6.         <meta charset="UTF-8" />
  7.         <title>Trouve ta recette</title>
  8.     </head>
  9.  <form method="POST" action="composition.php">
  10.             <input type="checkbox" name="lardon" value="1" />lardon
  11.             <input type="checkbox" name="jambon" value="1" />jambon
  12.             <input type="checkbox" name="tomate" value="1" />tomate
  13.             <input type="checkbox" name="pate" value="1" />pate
  14.             <input type="checkbox" name="riz" value="1" />riz
  15.             <input type="checkbox" name="creme" value="1" />creme
  16.             <input type="checkbox" name="pomme_de_terre" value="1" />pomme de terre
  17.             <input type="checkbox" name="viande_hachee" value="1" />viande hachée
  18.             <input type="checkbox" name="poisson" value="1" /> poisson
  19.             <input type="checkbox" name="eau" value="1" />eau
  20.             <input type="checkbox" name="fromage" value="1" />fromage
  21.             <input type="submit" value="Envoyer"/>
  22.  
  23.     </form>
  24.  
  25.  
  26.  
  27. <?php
  28. try
  29. {
  30.     $bdd=new PDO('mysql:host=localhost;dbname=phpisn2;charset=utf8','root','', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'', PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
  31.    
  32. }
  33. catch(PDOException $e)
  34. {
  35.     die('Erreur:'.$e->getMessage());
  36. }
  37.  
  38. if(isset($_POST['lardon'])){$lardon=1;} else {$lardon=0;}
  39. if(isset($_POST['jambon'])) {$jambon=1;} else {$jambon=0;}
  40. if(isset($_POST['tomate'])) {$tomate=1;} else {$tomate=0;}
  41. if(isset($_POST['pate'])) {$pate=1;} else {$pate=0;}
  42. if(isset($_POST['riz'])) {$riz=1;} else {$riz=0;}
  43. if(isset($_POST['creme'])) {$creme=1;} else {$creme=0;}
  44. if(isset($_POST['pomme_de_terre'])) {$pomme_de_terre=1;} else {$pomme_de_terre=0;}
  45. if(isset($_POST['viande_hachee'])) {$viande_hachee=1;} else {$viande_hachee=0;}
  46. if(isset($_POST['poisson'])) {$poisson=1;} else {$poisson=0;}
  47. if(isset($_POST['eau'])) {$eau=1;} else {$eau=0;}
  48. if(isset($_POST['fromage'])) {$fromage=1;} else {$fromage=0;}
  49.  
  50.  
  51.  
  52.  
  53.  
  54. $req = $bdd->query("SELECT recette FROM composition WHERE lardon=$lardon AND jambon=$jambon AND tomate=$tomate AND pate=$pate  AND riz=$riz AND creme=$creme AND pomme_de_terre=$pomme_de_terre AND viande_hachee=$viande_hachee AND poisson=$poisson AND eau=$eau AND fromage=$fromage");
  55.  
  56. while ($recette=$req->fetch())
  57. {
  58.     echo($recette['recette']).'<br />';
  59.     /*echo("<a href=".$recette['recette'].".html");*/
  60. }
  61.  
  62.  
  63. ?>
  64. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement