From da621eab70e3342957ad457f3c53e1632f01384f Mon Sep 17 00:00:00 2001
From: Ibrahima Bah <ibrahima.bah@etu.unistra.fr>
Date: Tue, 6 Dec 2022 09:32:43 +0100
Subject: [PATCH] =?UTF-8?q?depot=20des=20donn=C3=A9es=20de=20l'avaluation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Readme.md                        |  8 +++++++
 assets/actions/gameServer.php    | 18 +++++++++++++++-
 assets/actions/gameTableSize.php | 13 +++++++++++
 assets/actions/register.php      | 37 ++++++++++++++++++++++++++++++++
 assets/css/index.css             | 22 +++++++++++++++++++
 index.php                        | 11 ++++++++++
 6 files changed, 108 insertions(+), 1 deletion(-)

diff --git a/Readme.md b/Readme.md
index 5999c40..91f2534 100644
--- a/Readme.md
+++ b/Readme.md
@@ -67,3 +67,11 @@ copier/coller, je ne souhaite pas de définition toute faite, mais une réponse
 
 - Quel est le protocole utilisé pour communiquer avec le serveur ?
 - JS est un langage asynchrone ou synchrone ? Expliquez.
+
+
+reponse aux questions :
+
+1 - tout depend de la manière dont le cleint et le serveur sont implementés .
+le plus utmilé est le HTTP 
+
+2- js est un langage asynchrone cad que les instuctions dans un programme js ne s'executent pas necessairement dans l'ordre mais plutot de la maniere dont ils sont programés
\ No newline at end of file
diff --git a/assets/actions/gameServer.php b/assets/actions/gameServer.php
index dd6786d..9a66cfd 100644
--- a/assets/actions/gameServer.php
+++ b/assets/actions/gameServer.php
@@ -2,4 +2,20 @@
 
 // utiliser le fichier Database.php pour charger les trois premiers jeux dans la base de données et les retourner en JSON. (2 points)
 
-require_once __DIR__ . '/../db/Database.php';
+require_once __DIR__ . '/../db/Database.php',
+function loadData(){
+   $.ajax ({
+    url: "/assets/actions/gameServer.php",
+    method: "GET",
+    data : {limit : 3},
+    success :function(data){
+    $("main > section").html(data);
+    }
+});
+
+}
+
+$db= new DataBase("localhost","database_user","database_password","database_name");
+$games = $db->query("SELECT * FROM games LIMIT 3");
+echo json_encode($games);
+
diff --git a/assets/actions/gameTableSize.php b/assets/actions/gameTableSize.php
index ebe98e0..4843ab2 100644
--- a/assets/actions/gameTableSize.php
+++ b/assets/actions/gameTableSize.php
@@ -3,3 +3,16 @@
 // utiliser le fichier Database.php pour charger le nombre de jeu total dans la base et le retourner en JSON. (1 points)
 
 require_once __DIR__ . '/../db/Database.php';
+
+function loadTotalGameCount(){
+    $.ajax({
+        url: "assets/actions/gameTableSize.php",
+        method :"GET",
+        succes : function(data){
+            $("#total-game-count").text(data);
+        }
+    });
+}
+
+$db= new DataBase("localhost","database_user","database_password","database_name");
+$total = $db->query("SELECT COUNT(*) FROM games")[0]["COUNT(*)"];
\ No newline at end of file
diff --git a/assets/actions/register.php b/assets/actions/register.php
index c816c01..60bbb99 100644
--- a/assets/actions/register.php
+++ b/assets/actions/register.php
@@ -6,3 +6,40 @@
  */
 
 require_once __DIR__ . '/../db/Database.php';
+function insert(){
+    $username = $POST["username"];
+    $password = $POST["password"];
+    $db= new DataBase("localhost","database_user","database_password","database_name");
+   $result = $db->query("INSERT INTO users (username ,password) VALUES (?,?)",[$username,$password]);
+
+ if($result){
+    header("location : /login.php");
+
+ }else {
+    header("location : /register.php")
+ }
+}
+?>
+
+<!doctype html>
+<html lang="fr">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport"
+          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+    <title>INSCRIPTION </title>
+    <link rel="stylesheet" href="/../css/index.css">
+</head>
+<body>
+<form action ="assets/actions/register.php" method = "post">
+<h2> inscription</h2>
+<label for= "username"> nom utlisateur</label>
+<input type= "text" name = "username" id = "username" placeholder = " votre nom de user">
+
+<label for="password"> mot de passe </label>
+<input type= "password" name = "password" id = "password" placeholder = " votre mot de passe ">
+ </form>
+ </body>
+ </html>
+
+
diff --git a/assets/css/index.css b/assets/css/index.css
index 1ffcc07..dd9dec2 100644
--- a/assets/css/index.css
+++ b/assets/css/index.css
@@ -57,3 +57,25 @@ main {
         font-size: 0.75rem; }
 
 /*# sourceMappingURL=index.css.map */
+
+section {
+  display :flex;
+  flex-wrap :wrap ;
+}
+
+@madia (min-width : 1200px){
+  section > div {
+    width : 33.3333%;
+  }
+}
+@madia (min-width : 768px) and (max-width : 1199px){
+  section > div {
+    width : 50%;
+  }
+}
+
+@madia (max-width : 767px){
+  section > div {
+    width : 100%;
+  }
+}
diff --git a/index.php b/index.php
index 3641d20..dbbfb48 100644
--- a/index.php
+++ b/index.php
@@ -26,6 +26,17 @@ require_once __DIR__ . '/assets/template/head.php';
 
   <button>
     <?= $translate->getTrad('home.loadMore') ?>
+    <?php 
+    require_once '/assets/actions/gameServer.php';
+    $load("#load-more-button").click(function(){
+      loadData();
+    });
+
+        if($load){
+          ("#load-more-butooon").hide();
+        }
+    
+ ?>
   </button>
 </main>
 
-- 
GitLab