Assignment 1 and 2 – Internet Programming (ICT2613 – 2025)
Please note:
This document contains Assignments 1 and 2 for the module Internet Programming ICT2613 for the year 2025.
It is intended to serve as a guide. You are strongly advised not to copy and paste answers directly without
verifying the correct process for submission on myUnisa.
Use the content provided to understand the structure, extract what is relevant, and ensure your submission
complies with the module requirements.
Questions are indicated in red, while the corresponding answers are provided below each one.
Assignment 1 (chapters 1-6), Due Date: 13 May 11:00 PM, Total marks: 32 marks
1 = A (client-server application)
2 = D (PHP interpreter)
3 = C (Apache)
4 = B (uses localhost as the domain name)
5 = A (.htm)
6 = A (Code two slashes (//) followed by the comment)
7 = B (echo $votingAge;)
8 = B (POST)
9 = B (Name: Bob)
10 = B (20)
11 = B (foreign keys)
12 = C (SELECT)
13 = A (if the values of the primary key and foreign key are equal)
14 = B (a WHERE clause)
15 = A (http://localhost/phpmyadmin)
16 = B (PHP Data Objects)
17 = C (DSN (Data Source Name))
18 = A (fetch())
19 = C (PDOException object)
20 = C (foreach statement)
21 = D (the model and the view)
22 = A (make each layer as independent as possible)
23 = D (the application runs more efficiently)
24 = A (Model-View-Controller)
25 = A (controller)
26 = D (syntax error)
27 = D (multiplying by the wrong variable)
28 = A (runtime error)
, 29 = C (logic)
30 = A (fix all errors)
Assignment 2, Due Date: 23 June 11:00 PM, Total Marks: 60
Question 1 (10 marks)
<?php
// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = htmlspecialchars($_POST["name"]);
$language = $_POST["language"];
// Language greetings mapping
$greetings = [
"English" => "Hello",
"Afrikaans" => "Hallo",
"IsiXhosa" => "Molo",
"IsiZulu" => "Sawubona",
"Setswana" => "Dumela"
];
// Display greeting
if (array_key_exists($language, $greetings)) {
echo "<h2>" . $greetings[$language] . " " . $name . "</h2>";
} else {
echo "<h2>Invalid language selected.</h2>";
}
}
?>
Question 2 (10 marks)
Write a PHP program that inputs a number representing seconds and computes and displays the number of hours,
minutes and seconds from the input number.
For example, if the input is 5000 seconds, it is equivalent to 1 hour, 23 minutes and 20 seconds. Note that a minute
is 60 seconds and an hour is 60 minutes.
<?php
// Process form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$totalSeconds = (int)$_POST["seconds"];
// Calculate hours, minutes, and seconds
$hours = intdiv($totalSeconds, 3600);
$remainingSeconds = $totalSeconds % 3600;
$minutes = intdiv($remainingSeconds, 60);
$seconds = $remainingSeconds % 60;
// Display the result
echo "<h2>$totalSeconds seconds is equal to: </h2>";
echo "<p>$hours hour(s), $minutes minute(s), and $seconds second(s)</p>";
}
Please note:
This document contains Assignments 1 and 2 for the module Internet Programming ICT2613 for the year 2025.
It is intended to serve as a guide. You are strongly advised not to copy and paste answers directly without
verifying the correct process for submission on myUnisa.
Use the content provided to understand the structure, extract what is relevant, and ensure your submission
complies with the module requirements.
Questions are indicated in red, while the corresponding answers are provided below each one.
Assignment 1 (chapters 1-6), Due Date: 13 May 11:00 PM, Total marks: 32 marks
1 = A (client-server application)
2 = D (PHP interpreter)
3 = C (Apache)
4 = B (uses localhost as the domain name)
5 = A (.htm)
6 = A (Code two slashes (//) followed by the comment)
7 = B (echo $votingAge;)
8 = B (POST)
9 = B (Name: Bob)
10 = B (20)
11 = B (foreign keys)
12 = C (SELECT)
13 = A (if the values of the primary key and foreign key are equal)
14 = B (a WHERE clause)
15 = A (http://localhost/phpmyadmin)
16 = B (PHP Data Objects)
17 = C (DSN (Data Source Name))
18 = A (fetch())
19 = C (PDOException object)
20 = C (foreach statement)
21 = D (the model and the view)
22 = A (make each layer as independent as possible)
23 = D (the application runs more efficiently)
24 = A (Model-View-Controller)
25 = A (controller)
26 = D (syntax error)
27 = D (multiplying by the wrong variable)
28 = A (runtime error)
, 29 = C (logic)
30 = A (fix all errors)
Assignment 2, Due Date: 23 June 11:00 PM, Total Marks: 60
Question 1 (10 marks)
<?php
// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = htmlspecialchars($_POST["name"]);
$language = $_POST["language"];
// Language greetings mapping
$greetings = [
"English" => "Hello",
"Afrikaans" => "Hallo",
"IsiXhosa" => "Molo",
"IsiZulu" => "Sawubona",
"Setswana" => "Dumela"
];
// Display greeting
if (array_key_exists($language, $greetings)) {
echo "<h2>" . $greetings[$language] . " " . $name . "</h2>";
} else {
echo "<h2>Invalid language selected.</h2>";
}
}
?>
Question 2 (10 marks)
Write a PHP program that inputs a number representing seconds and computes and displays the number of hours,
minutes and seconds from the input number.
For example, if the input is 5000 seconds, it is equivalent to 1 hour, 23 minutes and 20 seconds. Note that a minute
is 60 seconds and an hour is 60 minutes.
<?php
// Process form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$totalSeconds = (int)$_POST["seconds"];
// Calculate hours, minutes, and seconds
$hours = intdiv($totalSeconds, 3600);
$remainingSeconds = $totalSeconds % 3600;
$minutes = intdiv($remainingSeconds, 60);
$seconds = $remainingSeconds % 60;
// Display the result
echo "<h2>$totalSeconds seconds is equal to: </h2>";
echo "<p>$hours hour(s), $minutes minute(s), and $seconds second(s)</p>";
}