ITEC3020 Assignment 2: PHP Web Site
Assignment 2 is based on the examples from Murach's book, Chapters 1 and 2, as discussed in class.
Asg 1
Asg 2 (1/3) Asg 2 (2/3) Asg 2 (3/3)
The assignment is split into 2 parts:
- Part 1 is a simplified version.
- Part 2 is an expanded version.
-
Part 2 can be built by starting with Part 1, updating existing code and adding new code. Corrections
No current corrections. Terminology
Numbers of the form 123456.0789 are called:
-
- in arithmetic
- rational numbers
- in computer science : floats or floating numbers We will call them floats. Floats have 3 components:
- a decimal point
- an integer part: the sequence of situated on the
- a decimal part: the sequence of situated on the digits (integer) left of the decimal point digits right of the decimal point
In some countries the decimal part is also called fractional part. In this assignment we will talk about float's decimal part. A2 Part 1: Simple web site using PHP
-
General requirements
-
You are expected to keep your code clean and simple, similar to the code from Murach.
-
Part 1 of A2 is a standalone web application called "a2part1".
-
In the Apache htdocs, you will have the following folders: a2/last5first1_789/a2part1
-
Any reference to files in the PHP or html pages should be relative to the web application root. Any reference to a file, which is specified by absolute path will lower your mark. Example: a reference of the form C:\3020\A3\myCss.css is absolute and is not acceptable.
-
Do not use graphics (graphical images). The total size of the A2 files sent to the TA cannot be larger than 500 Kilo Bytes.
-
- Files in a2part1 folder:
- 1) index.html
- see 2. below 2) TransformNumber.php : see 3. below 3) a2.css
- css file Attention: do not use any external JavaScript files. Chances are that the mail delivery system (google) will not allow you to send your assignment. Google flags .js files as potential viruses. If you need to use JavaScript, you can embed it in the .html and/or .php files.
-
To a. b. b. c.
test a2part2: In htdocs create a folder called a1 Inside a2, create a folder called last6first1_789 (see instructions in Common Part) Inside a2, copy a2part1 Test the
-
High level description
This is a PHP web application, which permits the user:
- to enter a float (real) number and
- to have a transformation applied on it.
Here transformation means:
T1. Standardize user number's decimal part length
T2. Reverse the digits of the given user number after standardization.
- Get a number from user (index.html) -------------------------------------This page is written in XHTML. On top, the page displays: "Input a number. It will be standardized and reversed." The page has one XHTML form, which has :
- One text input field, allowing the user to enter a float/real number, expected to be in the format: 999999.9999 We will call this number: User Number (UN).
- The text input is preceded (on the left) by a static text, explaining the expected input. For example: "Enter a number (format : 999999.9999) : ".
- One drop-down control, which allows the user to select one of following options: 1, 2, or 3. These options will be user's choice regarding the decimal part length in the transformed UN. We will call this field: ND_DP.
- The drop-down control is preceded (on the left) by a static text, explaining its function. For example: "Standardized number of digits in the decimal part : ".
- One submit button, whose name is SubmitNumber. Requirements :
- the form is submitted to TransformNumber.php when the user presses the submit button ;
- the submission method can be either get or post.
- Transform number page (TransformNumber.php) ---------------------------------------------This page is written in PHP.
- The page retrieves: a) the user input from index.html's text input field (UN) b) the user input from index.html's drop-down control (ND_DP) b) the name of the button pressed in index.html
- The page validates that: a) the index.html form was submitted by pressing the button SubmitNumber b) the string entered in the form: 1) is not empty, 2) is numeric and 3) has at most 4 digits after the decimal sign
- The page generates the following HTML :
- if the above validation (3.2) is false, the page displays : a) an error message, followed by b) a link to the index.html page ;
-
- if the above validation (3.2) is true, the page displays :
- the text "Your number transformed : ", followed by the number provided by
- the user with the following 2 transformations:
- T1) Transform the number input by the user (UN) to a new standardized number (SN),
- which has ND_DP decimal digits by one of the following:
- a) Truncation:
- when the number has more than ND_DP decimal digits
- b) Adding (1 or 2) zeroes: when the number has less than ND_DP decimal digits
- T2) Reverse the digits of SN.
- Examples: Suppose ND_DP = 2
- e1) user enters UN : 123456.789
- determine
- SN : 123456.78
- display
- 87.654321 e2) user enters UN : 123456.78 determine SN : 123456.78 display
- 87.654321 e3) user enters UN : 123456.7 determine SN : 123456.70 display
- 07.654321 e4) user enters UN : 123456 or 123456. determine SN : 123456.00 display
- 00.654321 Requirements:
- the index.html's form is submitted to TransformNumber.php when the user presses the submit button. Recommendations: 1) Study the Product Discount Application from Chapter 1 (Murach) and test it: download the source code, deploy it to Apache and run it by following the instructions provided on pages 14 to 31. 2) Optional: Study the two sample applications from Chapter 2.
Assignment 2 is based on the examples from Murach's book, Chapters 1 and 2, as discussed in class.
Asg 1
Asg 2 (1/3) Asg 2 (2/3) Asg 2 (3/3)
The assignment is split into 2 parts:
- Part 1 is a simplified version of Part 2. Part 1 requires minimal knowledge and use of PHP.
-
Part 2 is an expended version of Part 1. Part 2 can be programmed by starting with Part 1 and updating its code (changing and adding new code). Corrections
No current corrections. A2 Part 2: Three-page web site using PHP
- General requirements
- You are expected to keep your code clean and simple, similar to the code from Murach.
- Part 2 of A2 is a standalone web application called "a2part2". This should be the name of a folder in your Apache htdocs.
- In the Apache htdocs, you will have the following folders: a2/last5first1_789/a2part2
- Any reference to files in the PHP or html pages should be relative to the web application root. Any reference to a file, which is specified by absolute path will lower your mark. Example: a reference of the form C:\3020\A3\myCss.css is absolute and is not acceptable.
- Do not use graphics (graphical images). The total size of the A2 files sent to the TA cannot be larger than 500 Kilo Bytes.
- index.html
- GetNumber2.php
- AddNumbers.php
- Optional
Attention: do not use any external JavaScript files. Chances are that the mail delivery system (google) will not allow you to submit your assignment. Google flags .js files as potential viruses. If you need to use JavaScript, you can embed it in the .html and/or .php files.
-
Allow the user to transmit the first number N1 (index.html) -------------------------------------------------------------This page is written in XHTML. The page has one XHTML form, which has :
-
One text input field, allowing the user to enter a real number, expected to be in the format: 999999.999
-
The text input is preceded by static text, explaining the expected input. For example: "Enter the first number (format : 999999.999) :".
-
One submit button, whose name is SubmitNumber1. Requirements :
- the form is submitted to GetNumber2.php when the user presses the submit button ;
- the submission method can be either get or post.
-
Allow the user to transmit the second number N2 (GetNumber2.php) ------------------------------------------------------------------This page is written in PHP.
-
The page retrieves: a) the user input from index.html's text input field b) the name of the button pressed in index.html
-
The page validates that: a) the index.html form was submitted by pressing the button SubmitNumber b) the string entered in the form: 1) is not empty, 2) is numeric and 3) has at most 3 digits after the decimal sign
-
The page generates the following HTML :
-
if the above validation (2.2) is false, the page displays : a) an error message, followed by b) a link to the index.html page ;
-
if the above validation (2.2) is true, the page displays : a) the form specified below at 2.4.
-
If the above validation (2.2) is true, the page displays also one XHTML form, which has :
-
One text input field, allowing the user to enter a real number, expected to be in the format: 999999.999
-
The text input is preceded by static text, explaining the expected input. For example: "Enter the second number (format : 999999.999) :".
-
One submit button whose name is SubmitNumber or a link (HTML anchor). Requirements :
- the form is submitted to AddNumbers.php when the user presses the submit button or the link ;
- the submission method can be either get or post.
-
Add numbers page (AddNumbers.php) -----------------------------------This page is written in PHP.
-
The page retrieves: a) the user input from GetNumber2.php's text input field b) the name of the button pressed in GetNumber2.html, if the submission was made by using the SubmitNumber button.
-
The page validates that: a) the string entered in the form: 1) is not empty, 2) is numeric and 3) has at most 3 digits after the decimal sign
-
The page generates the following HTML :
-
if the above validation (2.2) is false, the page displays : a) an error message, followed by b) a link to the GetNumber2.php page ;
-
if the above validation (2.2) is true, the page displays : a) the text "Your number 1 : ", followed by the number provided by the user on index.html b) the text "Your number 2 : ", followed by the number provided by the user on GetNumber2.php c) the text "The sum of the 2 numbers : ", followed by the sum of the number provided by the user on index.html and of the number provided by the user on GetNumber2.php Comments and Hints: CH1. Part 2 of A2 (this application) is mostly based on a simplified Part 1. CH2. The new aspect in Part 2 is the requirement to add 2 numbers, where the first number N1 is gathered from one page and the second number N2 is gathered from another page. CH3. In our course, before the mid-term exam, we have studied several techniques, which allow us to find a solution to CH2. CH4. You can chose to implement any solution to solve CH3. The assignment asks you to code it and to document it. Recommendations: 1) Study the Product Discount Application from Chapter 1 (Murach) and test it:
- download the source code, deploy it to Apache and run it by following the instructions provided on pages 14 to 31.
- understand the logic and the code behind it. 2) Study the two sample applications from Chapter 2 (Murach) and test it:
- download the source code, deploy it to Apache and run it by following the instructions provided on pages 14 to 31.
- understand the logic and the code behind it.
A2 Part 3: Sending A2 for grading
Remark:
- Incorrect submissions will NOT be debugged
- a2part1 and a2part2 are two separate PHP applications, which (together)form A2
The following steps are required for sending correctly A2 for grading Steps 2 and 3 will help you to test your A2 package before sending it The following steps can be tested with any other two PHP applications Even more simple testing can be done as follows: use the application from Ch01 and copy it first to a2part1 and second to a2part2.
- In what follows: a) the words "folder" and "directory" will be used interchangeably. b) the string Last6First1_789_a2 must match your last name, first name and York U id as per "Delivery" on the left side.
- Following the instructions in Delivery (see left navigation menu), you have a personal folder with a name of the form: Last6First1_789_a2. This folder is called the A2 folder. Inside this folder create another folder called: Last6First1_789. This folder is the deployment folder.
- Copy the a2part1 application and a2part2 applications from Apache's htdocs folder in the Last6First1_789_a2/Last6First1_789 folder.
- Copy the Last6First1_789 folder (the deployment folder) to Apache's htdocs/a2 folder.
Observe: Inside htdocs you need to have a sub-folder called a2 ! Now, htdocs/a2 should have a folder, whose name is of the form: Last6First1_789. Re-test the a2part1 application and the a2part2 application, by using appropriate URLs. Observe that the new URLs have changed, because:
- the a2part1 application and a2part2 application are inside the Last6First1_789 folder (see 1 above)
- the Last6First1_789 folder is inside htdocs/a2
- the URLs to the two A2 applications will be of the form:
localhost/a2/Last6First1_789/a2part1
localhost/a2/Last6First1_789/a2part2
- Create a plain text file in the Last6First1_789_a2 folder and call it readme.txt In this file document:
- the links (URLs) needed to test your assignment. You can copy these links (URLs) from your browser's URL control, when you perform the tests at 3 above.
- how did you implement CH2-CH3 from Part 2.
Provide any other information needed to test your a2part1 application and
a2part2 application.
- Zip the A2 folder (Last6First1_789_a2 from your "3020 personal base directory") with all its content, which should have the following structure:
- Last6First1_789, which has 2 sub-folders:
a2part1 a2part2
- readme.txt file
To create the zip file, follow the instructions in Common Part (Zip Creation).
Observe that you need to zip the A2 folder (Last6First1_789_a2) and its contents,
NOT only its contents.
- Send the zip file to the TA following the instructions in Common Part (Delivery).