-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresult.php
More file actions
58 lines (46 loc) · 1.17 KB
/
result.php
File metadata and controls
58 lines (46 loc) · 1.17 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
48
49
50
51
52
53
54
55
56
57
58
<?php
require_once __DIR__ . '/questions.php';
$answers = array();
foreach ($QUESTIONS as $index => $q) {
$key = 'q' . $index;
if (isset($_POST[$key])) {
$answer = $_POST[$key];
array_push($answers, $answer);
}
}
$scores = array();
foreach ($answers as $type) {
if (!isset($scores[$type])) {
$scores[$type] = 0;
}
$scores[$type]++;
}
$bestType = null;
$bestScore = -1;
foreach ($scores as $type => $score) {
if ($score > $bestScore) {
$bestScore = $score;
$bestType = $type;
}
}
$result = $RESULTS[$bestType];
?>
<!doctype html>
<DOCTYPE lang="ja">
<head>
<meta charset="utf-8">
<title>診断結果 | <?php echo $TITLE; ?></title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1><?php echo $TITLE; ?></h1>
<div class="result-box">
<h2>診断結果</h2>
<h3><?php echo htmlspecialchars($result['title']); ?></h3>
<p><?php echo htmlspecialchars($result['message']); ?></p>
</div>
<div class="back-link">
<a href="index.php">もう一度診断する</a>
</div>
</body>
</html>