IT230-Assignment2.docx

Pg. 04

Question Four

Assignment 2

Deadline: Tuesday 30/03/2021 @ 23:59

[Total Mark for this Assignment is 5]

Web Technologies

IT230

Question One

1 Mark

Learning Outcome(s):

5. Build web applications using PHP or similar languages.

Write a PHP program to count the number of even and odd elements for the given array (2, 3, 4, 5, 6)

Question Two

1.5 Marks

Learning Outcome(s):

5. Build web applications using PHP or similar languages.

Write HTML and PHP code to create a Form similar to the one in the picture.

When the user press submit, the content will be sent to “Register.php”.

In Register.php document, if the user clicks submit and the checkbox has been selected, display the first name and last name as following.

However, if the user clicks submit and the checkbox has not been selected the following result will be shown.

Question Three

1.5 Marks

Learning Outcome(s):

5. Build web applications using PHP or similar languages.

You have the following HTML page that contains an input field for the user to enter his/her Email and a submit button:

<html>

<body>

<form action="process.php" method="post">

Enter your Email: <input type="text" name="Email"><br/>

<input type="submit">

</form>

</body>

</html>

The source code for process.php page is below. The page is simply displays the entered email.

<?php

echo $_POST["Email"];

?>

Suppose that an attacker types the following into the Email field:

<script> for (i = 0; i < 5; i++) alert("Hello! I am an alert box!"); </script>

I. What will happen? [0.5 mark]

II. What do we call this type of attack? [0.5 mark]

III. Re-write process.php so, it prevents this attack. [0.5 mark]

Question Four

1 Mark

Learning Outcome(s):

2. Design and manipulate web databases.

5. Build web applications using PHP or similar languages.

Create a MySQL database table named Employees as the following.

Write a PHP page that retrieves all employees’ First_name and Last_name who work in IT department.