Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.08 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <?php
  3.   include 'functions.php';
  4.   session_start();
  5.   if(isset($_GET['ranking'])){
  6.     if(isset($_GET['ID_PRO'])){
  7.       try {
  8.         $bdd = new PDO("mysql:host=localhost;dbname=vignerons", "root", "");
  9.         $bdd->query("SET NAMES 'utf8'");
  10.        
  11.         $idProduit = $_GET['ID_PRO'];
  12.        
  13.         $emailUser = $_SESSION['user'];
  14.        
  15.         $reponseClient = $bdd->query("SELECT * FROM utilisateur WHERE UTI_EMAIL = '$emailUser'");
  16.         $donneesClient = $reponseClient->fetch();
  17.         $idUser = $donneesClient['ID_UTI'];
  18.        
  19.         $ranking = $_GET['ranking'];
  20.        
  21.         $reponsefeed = $bdd->query("SELECT * FROM feedback WHERE ID_PRO_FEE= $idProduit AND ID_UTI_FEE = $idUser");
  22.         $nombrefeed = $reponsefeed->rowCount();
  23.         if ($nombrefeed == 0) {
  24.           $bdd->query("INSERT INTO feedback(ID_PRO_FEE, ID_UTI_FEE, FEE_NOTE) VALUES($idProduit, $idUser, $ranking)");
  25.         }
  26.         else {
  27.           $bdd->query("UPDATE feedback SET FEE_NOTE = $ranking WHERE ID_PRO_FEE = $idProduit AND ID_UTI_FEE = $idUser");
  28.         }
  29.       } catch (\Exception $e) {
  30.  
  31.       }
  32.  
  33.  
  34.     }
  35.   }
  36.  ?>
  37. <html>
  38. <head>
  39.   <meta charset="utf-8">
  40.   <link rel="stylesheet" href="cs.css">
  41.   <title>Index html</title>
  42. </head>
  43. <body>
  44.   <header>
  45.  
  46.   </header >
  47.  
  48.   <section>
  49.     <table id="tableauAumillieu">
  50.       <tr>
  51.         <td id="titre1">V I G N E R O N S</td>
  52.       </tr>
  53.       <tr>
  54.         <td id="titre">- 1975 -</td>
  55.       </tr>
  56.     </table>
  57.  
  58.     <table id="deuxiemeTableau">
  59.       <tr>
  60.         <td><a href="acceuil.php" target="_self">ACCEUIL</a></td>
  61.         <td><a href="nosProduits.php">NOS PRODUITS</a></td>
  62.         <td><a href="nosPointsDeVente.php">POINTS DE VENTE</a></td>
  63.         <td><a href="contact.php">CONTACT</a></td>
  64.         <td>
  65.         <?php
  66.         if (isset($_SESSION['user']) AND ($_SESSION['user'] != null)) {
  67.           ?>
  68.           <a href="logout.php"><?php echo "Not " . $_SESSION['user'] . " ?";?></a>
  69.           <?php
  70.         }
  71.         else {
  72.         ?>
  73.         <a href="Connexion.php">CONNEXION</a>
  74.         <?php
  75.         }
  76.       ?>
  77.         </td>
  78.       </tr>
  79.     </table>
  80.     <hr class="hr">
  81.  
  82.  
  83.  
  84.  
  85.   <?php
  86.  
  87.       try {
  88.         $bdd = new PDO("mysql:host=localhost;dbname=vignerons", "root", "");
  89.  
  90.         $bdd->query("SET NAMES 'utf8'");
  91.  
  92.         $reponse = $bdd->query("SELECT * FROM produit");
  93.  
  94.         $reponse->setFetchMode(PDO::FETCH_BOTH);
  95.  
  96.         while ( $donnees = $reponse->fetch() ){
  97.  
  98.           $connecte = true;
  99.  
  100.               if (isset($_SESSION['user']) AND ($_SESSION['user'] != null)) {
  101.  
  102.                 $emailUser = $_SESSION['user'];
  103.  
  104.                 $idProduit = $donnees['ID_PRO'];
  105.  
  106.                 $reponseClient = $bdd->query("SELECT * FROM utilisateur WHERE UTI_EMAIL = '$emailUser'");
  107.                 $donneesClient = $reponseClient->fetch();
  108.  
  109.                 $idUser = $donneesClient['ID_UTI'];
  110.  
  111.                 if (isset($_GET['FEE_NOTE'])) {
  112.                   $ranking = $_GET['FEE_NOTE'];
  113.  
  114.                   $reponsefeed = $bdd->query("SELECT * FROM feedback WHERE ID_PRO_FEE= $idProduit AND ID_UTI_FEE = $idUser");
  115.                   $nombrefeed = $reponsefeed->rowCount();
  116.  
  117.  
  118.                   if ($nombrefeed == 0) {
  119.                     $bdd->query("INSERT INTO feedback(ID_PRO_FEE, ID_UTI_FEE, FEE_NOTE) VALUES($idProduit, $idUser, $ranking)");
  120.                   }
  121.                   else {
  122.                     $bdd->query("UPDATE feedback SET FEE_NOTE = $ranking WHERE ID_PRO_FEE = $idProduit AND ID_UTI_FEE = $idUser");
  123.                   }
  124.                 }
  125.                 else {
  126.                   $reponsefeed = $bdd->query("SELECT * FROM feedback WHERE ID_PRO_FEE = $idProduit AND ID_UTI_FEE = $idUser");
  127.                   $nombrefeed = $reponsefeed->rowCount();
  128.  
  129.                   if ($nombrefeed != 0) {
  130.                     $donneesback = $reponsefeed->fetch();
  131.  
  132.                     $ranking = $donneesback['FEE_NOTE'];
  133.                   }
  134.                   else {
  135.                     $ranking = 99;
  136.                   }
  137.                 }
  138.               }
  139.               else {
  140.                 $connecte = false;
  141.               }
  142.  
  143.             ?>
  144.  
  145.  
  146.             <table>
  147.               <tr>
  148.                 <td><div class='cartouche'>
  149.                             <div class='card'>
  150.  
  151.                                 <br><br>
  152.                                 <div class='pict'>
  153.                                     <img class="imfinal" src="./<?= $donnees['PRO_LIENPHOTOS']?>" ><br><br><br>
  154.                                 </div>
  155.                             </div>
  156.                         </div>
  157.               </td>
  158.               <td>
  159.                 <div class='titreVinDeconnecte'>
  160.                     <?php echo $donnees['PRO_NOM']; ?></td>
  161.                 </div>
  162.  
  163.  
  164.               <td>
  165.                 <div class="symbole">
  166.  
  167.                   <?php
  168.                     if ($connecte == true) {
  169.  
  170.                     ?>
  171.                     <p class="titreVinFinal">  <?php
  172.                           echo $donnees['PRO_NOM'];
  173.                       ?></p>
  174.                       <?php
  175.                         if ($ranking == 99) {
  176.                         ?>
  177.                           <a href="nosProduits.php?ID_PRO=<?php echo $idProduit ; ?>&ranking=1"><img src="./Photos/sad-face-outline-unselected.png" class="icons"/></a>
  178.                           <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=2"><img src="./Photos/silent-emoticon-face-with-missed-mouth-symbol-of-stroke-unselected.png" class="icons"/></a>
  179.                           <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=3"><img src="./Photos/smiling-emoticon-face-unselected.png" class="icons"/></a>
  180.                         <?php
  181.                         }
  182.                         elseif ($ranking == 1) {
  183.                         ?>
  184.                           <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=1"><img src="./Photos/sad-face-outline-selected.png" class="icons"/></a>
  185.                           <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=2"><img src="./Photos/silent-emoticon-face-with-missed-mouth-symbol-of-stroke-unselected.png" class="icons"/></a>
  186.                           <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=3"><img src="./Photos/smiling-emoticon-face-unselected.png" class="icons"/></a>
  187.                         <?php
  188.                         }
  189.  
  190.                         elseif ($ranking == 2) {
  191.                         ?>
  192.                           <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=1"><img src="./Photos/sad-face-outline-unselected.png" class="icons"/></a>
  193.                           <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=2"><img src="./Photos/silent-emoticon-face-with-missed-mouth-symbol-of-stroke-selected.png" class="icons"/></a>
  194.                           <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=3"><img src="./Photos/smiling-emoticon-face-unselected.png" class="icons"/></a>
  195.                         <?php
  196.                         }
  197.  
  198.                         elseif ($ranking == 3) {
  199.                         ?>
  200.                           <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=1"><img src="./Photos/sad-face-outline-unselected.png" class="icons"/></a>
  201.                           <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=2"><img src="./Photos/silent-emoticon-face-with-missed-mouth-symbol-of-stroke-unselected.png" class="icons"/></a>
  202.                           <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=3"><img src="./Photos/smiling-emoticon-face-selected.png" class="icons"/></a>
  203.                         <?php
  204.                         }
  205.                         ?>
  206.  
  207.                     <?php
  208.                     }
  209.                   ?>
  210.                 </div>
  211.               </td>
  212.               </tr>
  213.             </table>
  214.                     <br>
  215.                     <?php
  216.                 }
  217.  
  218.             $bdd = NULL;
  219.             }
  220.             catch (PDOException $e) {
  221.                     echo "Erreur !: " . $e->getMessage() . "<br />";
  222.                     die();
  223.                 }
  224.             ?>
  225.   </section>
  226.  
  227.   <footer>
  228.  
  229.   </footer>
  230. </body>
  231. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement