College of Science, Engineering and Technology
⋄
ASSIGNMENT 3
Year Module — 2026
⋄
Module Code: ICT2613
Module Name: Internet Programming
Assignment No.: 3
Due Date: 03 August 2026
Semester: Year Module 2026
Submitted in partial fulfilment of the requirements for Internet Programming
at the University of South Africa.
,UNISA | ICT2613 Assignment 3 — Internet Programming
Task 1: Extracurricular Activity Registration Form (25 Marks)
Chapter reference: 7 | Page name: task1.php
This task requires building a PHP web form that registers school learners for extracurricular
activities, validates the submitted data, and displays a registration summary with fee calcula-
tion.
Display Registration Form
User Submits Form (GET)
All fields
filled?
No Yes
Display error: Display registration
“Form is incomplete” summary and total fee
Figure 1: Task 1 – Form Processing Flow
Question 1: How should the HTML form be structured?
The form uses the GET method as required by the assignment. Each field is labelled clearly.
The grade dropdown is populated programmatically using a PHP loop over grades 1 to 7. Six
extracurricular activities are listed as checkboxes: three are free (Soccer, Netball, Choir) and
three are paid (Chess at R150/term, Pottery at R200/term, Golf at R250/term). The form
also includes a text field for the learner’s full name and a submit button.
Key Distinction
The GET method appends form data to the URL as query string parameters. This is
appropriate for non-sensitive, idempotent operations such as a registration lookup. The
Page 1 of 33
,UNISA | ICT2613 Assignment 3 — Internet Programming
POST method sends data in the HTTP request body and is preferred for sensitive data.
This task explicitly requires GET.
Question 2: How should form validation be implemented?
Three conditions must all be satisfied before processing proceeds:
1. The full name field must not be empty.
2. A grade must be selected (not the default placeholder).
3. At least two checkbox activities must be selected.
If any condition fails, an error message is echoed to the page. If all conditions pass, the regis-
tration summary and total fee are displayed below the form.
Question 3: How is the total fee calculated?
The code iterates over the selected activities. Each activity has a predefined cost (R0 for free
activities). The total is accumulated in a variable and displayed using echo formatted with
South African Rand notation.
Complete PHP Code for task1.php
Listing 1: task1.php – Learner Extracurricular Registration Form
1 <?php
2 // menu . inc is included on every page for navigation
3 include ’ menu . inc ’;
4
5 // Define activities with their costs per term (0 = free )
6 $activities = [
7 " Soccer " => 0,
8 " Netball " = > 0 ,
9 " Choir " => 0,
10 " Chess " = > 150 ,
11 " Pottery " = > 200 ,
12 " Golf " = > 250 ,
13 ];
14 ?>
Page 2 of 33
,UNISA | ICT2613 Assignment 3 — Internet Programming
15 <! DOCTYPE html >
16 < html lang = " en " >
17 < head >
18 < meta charset = " UTF -8 " >
19 < title > Extracurricular Registration </ title >
20 < style >
21 body { font - family : Arial , sans - serif ; margin : 20 px ; }
22 label { display : block ; margin - top : 10 px ; font - weight : bold ; }
23 . error { color : red ; font - weight : bold ; }
24 . success - box { background : # e8f5e9 ; border : 1 px solid #388 e3c ;
25 padding : 15 px ; margin - top : 20 px ; border - radius : 5
px ; }
26 </ style >
27 </ head >
28 < body >
29 <h2 > School Extracurricular Activity Registration </ h2 >
30
31 <?php
32 // Form Processing
33 $errors = [];
34 $formSent = isset ( $_GET [ ’ submit ’ ]) ;
35
36 if ( $formSent ) {
37 // 1. Validate full name
38 $fullName = isset ( $_GET [ ’ fullname ’ ])
39 ? trim ( htmlspecialchars ( $_GET [ ’ fullname ’ ]) )
40 : ’ ’;
41 if ( empty ( $fullName ) ) {
42 $errors [] = " Full name is required . " ;
43 }
44
45 // 2. Validate grade selection
46 $grade = isset ( $_GET [ ’ grade ’ ]) ? $_GET [ ’ grade ’] : ’ ’;
47 if ( empty ( $grade ) || $grade === ’0 ’) {
48 $errors [] = " Please select a grade . " ;
49 }
50
Page 3 of 33
,UNISA | ICT2613 Assignment 3 — Internet Programming
51 // 3. Validate at least two activities selected
52 $selected = isset ( $_GET [ ’ activities ’ ])
53 ? $_GET [ ’ activities ’]
54 : [];
55 if ( count ( $selected ) < 2) {
56 $errors [] = " Please select at least two extracurricular
activities . " ;
57 }
58
59 // Display errors or registration summary
60 if (! empty ( $errors ) ) {
61 echo " <p class = ’ error ’> The form is incomplete . All fields
need "
62 . " to be filled : </p > < ul class = ’ error ’>" ;
63 foreach ( $errors as $err ) {
64 echo " <li > " . $err . " </ li > " ;
65 }
66 echo " </ ul > " ;
67 } else {
68 // Calculate total fee
69 $totalFee = 0;
70 foreach ( $selected as $act ) {
71 if ( isset ( $activities [ $act ]) ) {
72 $totalFee += $activities [ $act ];
73 }
74 }
75
76 // Display registration summary
77 echo " < div class = ’ success - box ’>" ;
78 echo " <h3 > Registration Confirmation </ h3 > " ;
79 echo " <p > < strong > Learner Name : </ strong > " . $fullName . " </p >
";
80 echo " <p > < strong > Grade : </ strong > " . $grade . " </p > " ;
81 echo " <p > < strong > Registered Activities : </ strong > </p > < ul > " ;
82 foreach ( $selected as $act ) {
83 $cost = $activities [ $act ];
84 $costStr = ( $cost == 0) ? " Free " : " R " . $cost . " / term " ;
Page 4 of 33
, UNISA | ICT2613 Assignment 3 — Internet Programming
85 echo " <li > " . htmlspecialchars ( $act )
86 . " ( " . $costStr . " ) </ li > " ;
87 }
88 echo " </ ul > " ;
89 echo " <p > < strong > Total Amount Payable per Term : R "
90 . $totalFee . " </ strong > </p > " ;
91 echo " </ div > " ;
92 }
93 }
94 ?>
95
96 <! - - HTML Form
-->
97 < form method = " GET " action = " task1 . php " >
98
99 < label for = " fullname " > Full Name of Learner : </ label >
100 < input type = " text " id = " fullname " name = " fullname "
101 value = "<?php echo $formSent
102 ? htmlspecialchars ( $_GET [ ’ fullname ’] ?? ’ ’)
103 : ’ ’; ?> " >
104
105 < label for = " grade " > Grade : </ label >
106 < select id = " grade " name = " grade " >
107 < option value = " 0 " >-- Select Grade - - </ option >
108 <?php
109 // Populate grades 1 to 7 using a loop
110 for ( $g = 1; $g <= 7; $g ++) {
111 $sel = ( $formSent && isset ( $_GET [ ’ grade ’ ])
112 && $_GET [ ’ grade ’] == $g ) ? ’ selected ’ : ’ ’;
113 echo " < option value = ’ $g ’ $sel > Grade $g </ option > " ;
114 }
115 ?>
116 </ select >
117
118 < label > Extracurricular Activities ( select at least 2) : </ label >
119 <?php
120 foreach ( $activities as $actName = > $actCost ) {
121 $label = ( $actCost == 0)
Page 5 of 33