-
Notifications
You must be signed in to change notification settings - Fork 1
/
save.php
38 lines (30 loc) · 816 Bytes
/
save.php
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
<?php
session_set_cookie_params(604800);
session_start();
// print_r($_SESSION["data"]);
// print_r($_POST);
// die();
$scores = [];
$vragen = [];
foreach ($_POST as $match => $score)
{
if(substr($match, 0, strlen("vraag_")) !== "vraag_")
$scores[$match] = $score;
else
$vragen[$match] = $score; //in dit geval gaat het om een bonusvraag
}
$_SESSION["data"]["scores"] = $scores;
$_SESSION["data"]["vragen"] = $vragen;
if(isset($_SESSION["user"]) && !empty($_SESSION["user"]))
{
$filename = "data/user/" . $_SESSION["user"] . ".json";
$fh = fopen($filename, 'w') or die("can't open file");
$stringData = json_encode($_SESSION["data"]);
fwrite($fh, $stringData);
fclose($fh);
}
else
{
$_SESSION["login"]["message"] = "Uw Sessie is verlopen. Gelieve opnieuw in te loggen.";
}
header("location: /");