diff --git a/Readme.md b/Readme.md index 5999c40e3b17c1e0f27e9cdef66895e76d9b9ad1..91f253448533b22b62a2813ba3346760da113d0e 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 dd6786de54ee418b9caca8d4781feab0f20e7364..9a66cfde2a7dfbdf64277aa883954868d038d2c1 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 ebe98e0cc4f72b90c37b601b4c256995d279273e..4843ab276b6006af393170c166de43570919e9fe 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 c816c019d41381bc9d56fbdf1d4bcbc1d0ee349f..60bbb993af446fb911023b92dcea8f168fa72aee 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 1ffcc07971331634b07b77f462778d6f1b7eab12..dd9dec202ae3b9e08132d8d9aac235421ed1929c 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 3641d208f513fd3b51c30c5165eea1f7cbc26f9b..dbbfb48e20b86393465a8fb9a75b1520a01613f2 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>