Assignment 1 - Dynamic Web Application Using PHP
Assignment 1 - Dynamic Web Application Using PHP
Total Marks: 50
This assignment should be done after completing Module 2. It will re-enforce the PHP concepts that we have discussed in
Module 2.
Complete each task following the recommendations provided in the problem description. Remember to properly comment and
organize your code as well as provide proper instructions about how to run and test the application.
Submission Instructions
1. First, create separate folders (containing all the files). If you are using NetBeans, then you do not need to create separate
folders; instead you can use the NetBeans project folders.
2. Create a “readme” containing instructions to run and test your code/application.
3. Next, put all the files in another folder named COMP3541_A1_xxx_yyy, where xxx and yyy should be your first and last
name, respectively.
4. Finally, compress (use zip) that folder and submit the compressed folder it in Moodle.
Tasks
1. Enhance the Product Discount application from Chapter 2 of your textbook (ch02_product_discount) by adding the
following features:
1. Display the results below the form (on the same page) instead of on a separate page. (3 marks)
2. After each calculation, set the values in the text boxes to empty strings. (2 marks)
3. Add a check box at the bottom of the first page that says: “Compound Interest Monthly”. If this box is checked, the
interest should be calculated monthly instead of yearly, so you need to change the Future Value calculation to provide
for that. (3 marks)
4. Also display some text that indicates whether the interest is being calculated monthly or yearly. (2 marks)
3. Create a simple PHP application that will ask users to enter Name, E-Mail, and Phone Number values (see the first figure),
and when the submit button is clicked, will then use the data from the text fields to add more lines at the end of the
message (see the second figure). Make sure you add appropriate input validations for all the fields. (10 marks)
1/4
Then, test your application by entering appropriate data in the name, e-mail, and phone number boxes.
4. Create a web form to help in creating simple random passwords. Your web form should have four text fields named Word1,
Word2, Word3, and Word4, as well as “Reset” and “Submit” buttons. You need to create a separate PHP form-processing
script that verifies that all four words are entered, that all of them contain only letters, and that all four are between 4 and 7
characters long. Once all of the words have been verified as correct, use the strtoupper() and str_shuffle() functions to
produce four suggested jumbled sets of passwords using the words entered in the text fields. (10 marks)
Note 1: In real world application, you should validate the inputs on the client side, but for this assignment, you need to
perform the validation on the server side using PHP scripts.
Note 2: An easier way to check if a text field contains only characters is to use regular expressions (we will learn regular
expressions in Module 7). However, if you want, you can go ahead and study the preg_match() function and use it in this
assignment to check for the letters only.
5. A palindrome is a word or phrase that is identical when you read from forward or backward, such as the words “racecar”
and “madam.” A standard palindrome is similar to a perfect palindrome, except that spaces and punctuation are ignored in
a standard palindrome. For example, “Madam, I’m Adam” is a standard palindrome because the characters are identical
forward or backward, provided you remove the spaces and punctuation marks. Write a PHP script that checks words or
phrases stored in two separate string variables to determine if they are a perfect palindrome. In addition, see if you can
modify the program to check for standard palindromes.
As part of the assignment, create a web page with a text field and “Reset” and “Submit” buttons. When a user clicks on the
submit button, show the standard and perfect palindromes of the string that was entered in the text field on the same page.
(10 marks)
2/4
6. Enhance the Task List Manager application from Exercise 11-1 in Chapter 11 of your textbook (ch11_ex1) by adding a
“Demote Task” option. Add code that allows the user to demote a task. This code should move the selected task down one
index in the array of tasks. If the user selects the last task, this code should display an error message that indicates that
you cannot demote the last task. (5 marks)
Note
You should start with the codes after competing Exercise 11-1 in Chapter 11 of your textbook.
See a test run example for guidelines:
Criteria Value
The task is complete 60%
The recommendations provided in the problem description were followed. 20%
Codes are properly commented and organized. 15%
Proper instructions are given to run and test the application. 5%
Add submission
Submission status
Last modified -
3/4
Submission comments
Comments (0)
4/4