Advertisement
raphael76280

Untitled

Mar 18th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.42 KB | None | 0 0
  1. <?php
  2. function bdd(){
  3.  
  4.  
  5. try
  6. {
  7.     $bdd = new PDO('mysql:host=IPADRESS;dbname=NAME;charset=utf8', 'USERNAME', 'PASS');
  8. }
  9. catch (Exception $e)
  10. {
  11.         die('Erreur : ' . $e->getMessage());
  12.  
  13. }
  14. return $bdd;
  15. }
  16.  
  17. $bdd = bdd();
  18.  
  19.  
  20.         if (isset($_GET['save'])){
  21.             if ($_GET['save'] == "yes"){
  22.             $req = $bdd->prepare("INSERT INTO wwiii(type, j1, j2, j3, j4, date) VALUES (:type, :j1, :j2, :j3, :j4, :date)");
  23.             $req->execute(array(
  24.             'type' => $_POST['type'],
  25.             'j1' => $_POST['j1Suffix']. ": " .$_POST['j1'],
  26.             'j2' => $_POST['j2Suffix']. ": " .$_POST['j2'],
  27.             'j3' => $_POST['j3Suffix']. ": " .$_POST['j3'],
  28.             'j4' => $_POST['j4Suffix']. ": " .$_POST['j4'],
  29.             'date' => date("Y-m-d")
  30.  
  31.             ));
  32.             header("Location: scoreboard.php");
  33.             }
  34.         }else{
  35.                 if (isset($_GET['type']) && isset($_GET['date'])){
  36.                     if (!empty($_GET['type']) && !empty($_GET['date'])){
  37.                         $date = $_GET['date'];
  38.                         $type = $_GET['type'];
  39.  
  40.                         $j1 = $_GET["j1"];
  41.                         $j2 = $_GET["j2"];
  42.                         $j3 = $_GET["j3"];
  43.                         $j4 = $_GET["j4"];
  44.  
  45.                         $page = '<form action="scoreboard.php?save=yes" method="post">';
  46.                            
  47.                         $page .= '<input type="text" name="date" value="'.$date.'" hidden></input>';
  48.                         $page .= '<input type="text" name="type" value="'.$type.'" hidden></input>';
  49.                         $page .= '<input type="text" name="j1" value="'.$j1.'" hidden></input>';
  50.                         $page .= '<input type="text" name="j2" value="'.$j2.'" hidden></input>';
  51.                         $page .= '<input type="text" name="j3" value="'.$j3.'" hidden></input>';
  52.                         $page .= '<input type="text" name="j4" value="'.$j4.'" hidden></input>';
  53.  
  54.                         $page .= '<label for="j1Suffix">Surnom du J1</label>';
  55.                         $page .= '<input type="text" name="j1Suffix"></input>';
  56.  
  57.                         $page .= '<label for="j2Suffix">Surnom du J2</label>';
  58.                         $page .= '<input type="text" name="j2Suffix"></input>';
  59.  
  60.                         $page .= '<label for="j3Suffix">Surnom du J3</label>';
  61.                         $page .= '<input type="text" name="j3Suffix"></input>';
  62.  
  63.                         $page .= '<label for="j4Suffix">Surnom du J4</label>';
  64.                         $page .= '<input type="text" name="j4Suffix"></input>';
  65.  
  66.  
  67.  
  68.                         $page .= '<input type="text" name="save" value="yes" hidden></input>';
  69.                        
  70.                         $page .= '<input type="submit"></input>';
  71.        
  72.                         $page .= '</form>';
  73.  
  74.                         echo $page;
  75.                     }
  76.  
  77.                 }
  78.             }
  79.        
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87. $tableau = " ";
  88.  
  89.                     $userquery = $bdd->query("SELECT * FROM `wwiii` ORDER BY `id` DESC");
  90.  
  91.                     if(($userquery->rowCount())>0){
  92.  
  93.                         $i = 1;
  94.  
  95.                         while ($command = $userquery->fetch()){
  96.  
  97.                            
  98.  
  99.                             $ligne = "<tr><td>";
  100.  
  101.                             $ligne .= $command['date'];
  102.  
  103.                             $ligne .= "</td><td>";
  104.  
  105.                             $ligne .= $command['type'];
  106.  
  107.                             $ligne .= "</td><td>";
  108.  
  109.                             $ligne .= $command['j1'];
  110.  
  111.                             $ligne .= "</td><td>";
  112.  
  113.                             $ligne .= $command['j2'];
  114.  
  115.                             $ligne .= "</td><td>";
  116.  
  117.                             $ligne .= $command['j3'];
  118.  
  119.                             $ligne .= "</td><td>";
  120.  
  121.                             $ligne .= $command['j4'];
  122.  
  123.                             $ligne .= "</td><tr>";
  124.  
  125.                             if ($i < 10 ){
  126.  
  127.                                 $tableau .= $ligne;
  128.  
  129.                                 $i++;
  130.  
  131.                             }
  132.  
  133.  
  134.  
  135.                         }
  136.  
  137.  
  138.                     }else{
  139.  
  140.                             echo "<tr><td>Aucun score pour le moment ! a vous de jouer !</td></tr>";
  141.  
  142.                         }
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  ?>
  152.  
  153.  <!DOCTYPE html>
  154.  <html>
  155.  <head>
  156.     <title>FireStreak</title>
  157.     <style type="text/css">
  158.         * {
  159.             margin: 0px;
  160.            
  161.             color:  white;
  162.         }
  163.  
  164.         body {
  165.             display: flex;
  166.             justify-content: space-around;
  167.             background-color: black;
  168.             flex-direction: column;
  169.             align-items: center;
  170.         }
  171.  
  172.         table {
  173.             width: 80vw;
  174.             margin-top: 10vh;
  175.         }
  176.  
  177.         #particles-js {
  178.             position: absolute;
  179.             width: 100vw;
  180.             height: 100vh;
  181.             z-index: -1;
  182.         }
  183.  
  184.         form {
  185.             display: flex;
  186.             justify-content: space-around;
  187.             width: 80vw;
  188.             height: 40vh;
  189.             align-items: center;
  190.             flex-direction: column;
  191.         }
  192.  
  193.         input {
  194.             color: black;
  195.         }
  196.  
  197.     </style>
  198.     <script src="particles.js"></script>
  199.     <script type="text/javascript">
  200.         particlesJS.load('particles-js', 'particles.json', function() {
  201.             console.log('callback - particles.js config loaded');
  202.         });
  203.     </script>
  204.  </head>
  205.  <body>
  206.     <div id="particles-js"></div>
  207.     <table>
  208.         <tr>
  209.             <td><h1>Date</h1></td>
  210.             <td><h1>Mode</h1></td>
  211.             <td><h1>Joueur 1</h1></td>
  212.             <td><h1>Joueur 2</h1></td>
  213.             <td><h1>Joueur 3</h1></td>
  214.             <td><h1>Joueur 4</h1></td>
  215.         </tr>
  216.         <?php echo $tableau; ?>
  217.     </table>
  218.  </body>
  219.  </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement