-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresults.php
More file actions
98 lines (82 loc) · 2.03 KB
/
results.php
File metadata and controls
98 lines (82 loc) · 2.03 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
require_once "functions.php";
if (
empty($_POST['student_name']) ||
empty($_POST['grade1']) ||
empty($_POST['grade2']) ||
empty($_POST['grade3'])
) {
echo "Please fill in all fields.";
echo '<br><a href="index.php">Go back</a>';
exit;
}
$studentName = $_POST['student_name'];
$grades = [
$_POST['grade1'],
$_POST['grade2'],
$_POST['grade3']
];
$average = calculateAverage($grades);
$performance = getPerformance($average);
$message = getResultMessage($average);
if ($average >= 10) {
$resultClass = "success";
} else {
$resultClass = "error";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Results</title>
<style>
body {
font-family: Arial;
background-color: #f4f6f8;
}
.container {
width: 400px;
margin: 60px auto;
background: white;
padding: 25px;
border-radius: 8px;
}
.success {
background-color: #d4edda;
color: #155724;
padding: 12px;
border-radius: 5px;
font-weight: bold;
}
.error {
background-color: #f8d7da;
color: #721c24;
padding: 12px;
border-radius: 5px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<h1>Student Results</h1>
<p><strong>Name:</strong> <?php echo $studentName; ?></p>
<h3>Grades</h3>
<ul>
<?php
foreach ($grades as $grade) {
echo "<li>$grade</li>";
}
?>
</ul>
<p><strong>Average:</strong> <?php echo number_format($average, 2); ?></p>
<p><strong>Performance:</strong> <?php echo $performance; ?></p>
<div class="<?php echo $resultClass; ?>">
<?php echo $message; ?>
</div>
<br>
<a href="index.php">Back to form</a>
</div>
</body>
</html>