forked from LeMoutonElectrique/StageAlexy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsauver.php
More file actions
47 lines (31 loc) · 1.06 KB
/
sauver.php
File metadata and controls
47 lines (31 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
$supports_brut = $_GET["support_jeu"];
$supports = explode(",", $supports_brut);
$nouveau_jeu = array(
"nom" => $_GET["nom_jeu"],
"prix" => $_GET["prix_jeu"],
"image" => "bayonetta2.jpg",
"date" => $_GET["date_jeu"],
"support" => $supports);
@$json = file_get_contents("jeux.json");
$listeJeux=json_decode($json, true);
foreach ($nouveau_jeu as $key => $value) {
if($value == NULL){
echo "VOUS DEVEZ REMPLIR TOUS LES CHAMPS POUR VALIDER ! RETOUNEZ A LA PAGE PRECEDENTE POUR TERMINER DE REMPLIR LE FORMULAIRE !";
exit();
}
}
foreach ($listeJeux as $key => $value) {
if(in_array($_GET['nom_jeu'], $value)){
echo "CE JEU EXISTE DEJA !";
exit();
}
}
array_push($listeJeux, $nouveau_jeu);
$nouvelle_liste_jeux = json_encode($listeJeux, JSON_PRETTY_PRINT);
//echo $nouvelle_liste_jeux;
file_put_contents("jeux.json", $nouvelle_liste_jeux);
//var_dump($listeJeux);
echo "<h2 align=\"center\">Votre jeu a bien été rajouté à la liste</h2>"."\n";
echo "<a href=\"produits.php\"><button align=\"center\">Retourner aux produits</button></a>"."\n";
?>