// ================== TASK 1 ================== // Extracurricular Activity Registration Form // Activities array with cost and type $activities = [ 'soccer' => ['label' => 'Soccer', 'cost' => 150, 'type' => 'paid'], 'netball' => ['label' => 'Netball', 'cost' => 150, 'type' => 'paid'], 'chess' => ['label' => 'Chess', 'cost' => 100, 'type' => 'paid'], 'pottery' => ['label' => 'Pottery', 'cost' => 0, 'type' => 'free'], 'choir' => ['label' => 'Choir', 'cost' => 0, 'type' => 'free'], 'golf' => ['label' => 'Golf', 'cost' => 0, 'type' => 'free'] ]; // ================== FORM PROCESSING ================== if (isset($_GET['submit'])) { $fullname = isset($_GET['fullname']) ? trim($_GET['fullname']) : ''; $grade = isset($_GET['grade']) ? $_GET['grade'] : ''; $selectedActivities = isset($_GET['activities']) ? $_GET['activities'] : array(); // Validation $errors = array(); if (empty($fullname)) { $errors[] = "Please enter the learner's full name."; } if (empty($grade)) { $errors[] = "Please select a grade."; } if (count($selectedActivities) < 2) { $errors[] = "Please select at least two extracurricular activities."; } // Display errors or success if (!empty($errors)) { echo '
Learner: " . htmlspecialchars($fullname) . "
"; echo "Grade: " . htmlspecialchars($grade) . "
"; echo "Activities registered for: " . implode(', ', $activityNames) . "
"; echo "Total amount to be paid: R" . number_format($totalCost, 2) . "
"; echo '