Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function bdd(){
- try
- {
- $bdd = new PDO('mysql:host=IPADRESS;dbname=NAME;charset=utf8', 'USERNAME', 'PASS');
- }
- catch (Exception $e)
- {
- die('Erreur : ' . $e->getMessage());
- }
- return $bdd;
- }
- $bdd = bdd();
- if (isset($_GET['save'])){
- if ($_GET['save'] == "yes"){
- $req = $bdd->prepare("INSERT INTO wwiii(type, j1, j2, j3, j4, date) VALUES (:type, :j1, :j2, :j3, :j4, :date)");
- $req->execute(array(
- 'type' => $_POST['type'],
- 'j1' => $_POST['j1Suffix']. ": " .$_POST['j1'],
- 'j2' => $_POST['j2Suffix']. ": " .$_POST['j2'],
- 'j3' => $_POST['j3Suffix']. ": " .$_POST['j3'],
- 'j4' => $_POST['j4Suffix']. ": " .$_POST['j4'],
- 'date' => date("Y-m-d")
- ));
- header("Location: scoreboard.php");
- }
- }else{
- if (isset($_GET['type']) && isset($_GET['date'])){
- if (!empty($_GET['type']) && !empty($_GET['date'])){
- $date = $_GET['date'];
- $type = $_GET['type'];
- $j1 = $_GET["j1"];
- $j2 = $_GET["j2"];
- $j3 = $_GET["j3"];
- $j4 = $_GET["j4"];
- $page = '<form action="scoreboard.php?save=yes" method="post">';
- $page .= '<input type="text" name="date" value="'.$date.'" hidden></input>';
- $page .= '<input type="text" name="type" value="'.$type.'" hidden></input>';
- $page .= '<input type="text" name="j1" value="'.$j1.'" hidden></input>';
- $page .= '<input type="text" name="j2" value="'.$j2.'" hidden></input>';
- $page .= '<input type="text" name="j3" value="'.$j3.'" hidden></input>';
- $page .= '<input type="text" name="j4" value="'.$j4.'" hidden></input>';
- $page .= '<label for="j1Suffix">Surnom du J1</label>';
- $page .= '<input type="text" name="j1Suffix"></input>';
- $page .= '<label for="j2Suffix">Surnom du J2</label>';
- $page .= '<input type="text" name="j2Suffix"></input>';
- $page .= '<label for="j3Suffix">Surnom du J3</label>';
- $page .= '<input type="text" name="j3Suffix"></input>';
- $page .= '<label for="j4Suffix">Surnom du J4</label>';
- $page .= '<input type="text" name="j4Suffix"></input>';
- $page .= '<input type="text" name="save" value="yes" hidden></input>';
- $page .= '<input type="submit"></input>';
- $page .= '</form>';
- echo $page;
- }
- }
- }
- $tableau = " ";
- $userquery = $bdd->query("SELECT * FROM `wwiii` ORDER BY `id` DESC");
- if(($userquery->rowCount())>0){
- $i = 1;
- while ($command = $userquery->fetch()){
- $ligne = "<tr><td>";
- $ligne .= $command['date'];
- $ligne .= "</td><td>";
- $ligne .= $command['type'];
- $ligne .= "</td><td>";
- $ligne .= $command['j1'];
- $ligne .= "</td><td>";
- $ligne .= $command['j2'];
- $ligne .= "</td><td>";
- $ligne .= $command['j3'];
- $ligne .= "</td><td>";
- $ligne .= $command['j4'];
- $ligne .= "</td><tr>";
- if ($i < 10 ){
- $tableau .= $ligne;
- $i++;
- }
- }
- }else{
- echo "<tr><td>Aucun score pour le moment ! a vous de jouer !</td></tr>";
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>FireStreak</title>
- <style type="text/css">
- * {
- margin: 0px;
- color: white;
- }
- body {
- display: flex;
- justify-content: space-around;
- background-color: black;
- flex-direction: column;
- align-items: center;
- }
- table {
- width: 80vw;
- margin-top: 10vh;
- }
- #particles-js {
- position: absolute;
- width: 100vw;
- height: 100vh;
- z-index: -1;
- }
- form {
- display: flex;
- justify-content: space-around;
- width: 80vw;
- height: 40vh;
- align-items: center;
- flex-direction: column;
- }
- input {
- color: black;
- }
- </style>
- <script src="particles.js"></script>
- <script type="text/javascript">
- particlesJS.load('particles-js', 'particles.json', function() {
- console.log('callback - particles.js config loaded');
- });
- </script>
- </head>
- <body>
- <div id="particles-js"></div>
- <table>
- <tr>
- <td><h1>Date</h1></td>
- <td><h1>Mode</h1></td>
- <td><h1>Joueur 1</h1></td>
- <td><h1>Joueur 2</h1></td>
- <td><h1>Joueur 3</h1></td>
- <td><h1>Joueur 4</h1></td>
- </tr>
- <?php echo $tableau; ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement