# Lab 5 - Basic PHP Scripting

# General

N.B. the formula to convert celsius to fahrenheit is: 9.0/5.0*celsius + 32

All the of the files you are to create for this assignment should include your header.php and footer.php files created as part of the last assignment (including creating Lab 5 specific $file, $date, $description, $title, and $banner variables that are echoed in the header.php file). This will entail you actually making the files of type _.php (instead of _.html that the book asks for). You are also expected to place a header <h1> element (this could be your $banner variable) and a paragraph <h1> description on each of the the lab5*.php pages you create for this assignment.

NOTE: All pages must validate to the XHTML strict standard

Read Chapter 6: Using PHP Variables in the Julie Meloni text from DC Library eResources(see the steps in Lab 4 General tab, and the the first two pages of Appendix C: Writing Your Own Functions and Objects out of the course text book (skip the section on Objects). Take note that in Appendix C the include function is explained.

NOTE: If the link above does not allow you to access the textbook, re-visit the steps on the General tab from Lab 4 to access Durham Vollege e-Resources.

After completing the readings, work through all the php examples in Chapter 6 - Using PHP Variables.

WARNING

Be sure to place single-quotes around the terms val1, val2 and calc in your array element names in the calculate example. i.e. instead of $_POST[val1] you should type $_POST['val1'] (it will cause an warning in PHP if you do not).

# Due Date

The due date for Lab 5 is found on the Important Dates page and in DC Connect. This means that you must have published your website into your development folder on the opentech server and have submitted a clickable HTML link to your website on the opentech server in the Lab 5 assessment dropbox comment section in DC Connect (see "Submission" section).

You will be given a mark out of twenty (20). You will be told of the reasons for any loss of marks, these points are to be used as constructive criticism (i.e. fix the problems as a practice for the term tests).

# Specific Requirements

  • If you incorporated all of the lab4*.php files into your vertical nav bar as part of the last assignment, remove them and place them into the lab4.php file. (You cannot have every page on your site included in the vertical nav bar, it will become too long and ugly).
  • Be sure that all your pages are visually appealing with a consistent look and feel. To acheive this, you are to incorporate your webd2201.css stylesheet and your header.php and footer.php for all files created as part of this assignment.

  • Similar to the last assignment, include C-style PHP comments:

/*
    your_name
    assignment_date
    WEBD2201
*/

with your name, the date and the course code at the top of any/all lab5*.php PHP files (in a <?php ... ?> section so they do not show up on the page) created for this assignment. Additionally, add <!-- HTML Comments --> to all your pages that give your name, the file name, the date the file was created and a brief description of what the page does. NOTE: this should be achieved by declaring appropriately name PHP variables before calling the include("header.php"); and then echoing the variables ($file, $date and $desc) in their appropriate locations.

  • Additionally, your pages' <title> and <h1> banner should be set dynamically by echoing the $title and $banner PHP variables into the header.php file.

  • You are to create a lab5.php file that will act as the main navigation page for all files created for this assignment. In addition to having a link to this page in your site's main nav bar, you are to incorporate a clearly labeled link on each page created as part of this assignment back to the lab5.php page. Like all your pages, you should have a header and paragraph explaining on each page the page's purpose.

  • Chapter 6 in the text has you create the files: calculate_form.php; calculate.php; phpinfo.php; remoteaddress.php; and, useragent.php. You do Not have to incorporate the phpinfo.php as part of your website (though working through the example is still worthwhile). All of the files created should have a *.php file extension (so they can include your header and footer). As well, each of your filenames should be pre-fixed with lab5 (i.e. remoteaddress.php should be called lab5_remoteaddress.php or lab5remoteaddress.php).
  • In addition to the text examples, you are to create two (2) temperature conversion pages (one to be named lab5_simple_temp_convert.php and another called lab5_function_temp_convert.php. These two conversion pages will utilize a for loop that starts at a celsius temperature of -40° and loops to a temperature of 100° inclusive by increments of 10°, converting each celsius temperature to its equivalent fahrenheit temperature. To see what the instructor is looking for link to an example temperature conversion page. To include the degree sign you must include ° beside the number in the output. Reminder: be sure you give access to all these lab 5 pages from the file lab5.php.
  • The first temperature conversion page should perform the calculation of the conversion directly in the for loop, the second page (whose table will look indentical to the first) instead should do the calculation in an appropriately named function.

# Rubric

Topic Description Weighting
Submission
Submission
-2 files not published into your /var/www/html/webd2201/userid main folder (instead in /home/userid folder).

-2 no link submitted in DC Connect Lab 5 assignment drop box

-1 link in DC Connect Lab 5 assignment drop box not clickable

-1 link in DC Connect Lab 5 assignment drop box does not go to your website

/2
Deliverable Specific Outcomes
Comments/Description paragraphs
-3 <!-- HTML Comments --> are not dynamic (i.e. hard-coded once and/or do not echo declared variables ($file, $date, $desc, $title, $banner) in the header.php file.

-2 dynamic <!-- HTML Comments --> not echo'ed in the header.php file (implemented incorrectly) -2 missing /* c-style */ comments on most/all of your lab*.php pages.

-2 missing detailed description paragraph on lab.php

-1 description paragraph on lab.php light on content

-1 lab_remoteaddress.php missing description paragraph

-1 lab_useragent.php missing description paragraph

-1 lab_calculate_form.php missing description paragraph

-1 lab_calculate.php missing description paragraph

-1 lab_simple_temp_convert.php missing description paragraph

-1 lab_function_temp_convert.php missing description paragraph

-0.5 lab_remoteaddress.php description paragraph light on content/not descriptive

-0.5 lab_useragent.php description paragraph light on content/not descriptive

-0.5 lab_calculate_form.php description paragraph light on content/not descriptive

-0.5 lab_calculate.php description paragraph light on content/not descriptive

-0.5 lab_simple_temp_convert.php description paragraph light on content/not descriptive

-0.5 lab_function_temp_convert.php description paragraph light on content/not descriptive
/5
lab5.php Page
-4 no lab5.php created.

-1 link to lab5_remoteaddress.php is broken

-1 link to lab5_useragent.php is broken

-1 link to lab5_calculate_form.php is broken

-1 link to lab5_calculate.php is broken

-1 link to lab5_simple_temperature_conversion.php is broken

-1 link to lab5_function_temperature_conversion.php is broken

/4
lab5_*.php Pages from Textbook
-3 textbook example files do not have the lab5 prefix in their filenames.

-1 lab5_remoteaddress.php not created

-1 lab5_useragent.php not created

-1 lab5_calculate_form.php not created

-1 lab5_calculate.php not created

-0.5 lab5_calculate.php does not work

-0.5 lab5_remoteaddress.php does not work

-0.5 lab5_useragent.php not does not work

-0.5 lab5_calculate_form.php does not work/ has incorrect URL for action attribute

-0.5 lab5_calculate.php not completed (did not code the PHP snippet)

-0.5 lab5_remoteaddress.php not completed (did not code the PHP snippet)

-0.5 lab5_useragent.php not completed (did not code the PHP snippet)

-0.5 lab5_calculate_form.php not completed (did not code the PHP snippet)

-0.5 lab5_calculate.php not completed (did not code the PHP snippet)

/5
Simple Temperature Conversion
-1 file not named correctly (i.e. lab5_simple_temp_convert.php)

-2 the temperature conversion was not created by a loop performing the calculation (i.e. table of data is hard-coded

-1 loop does not start at -40° celsius and/or does not stop at 100° celsius and/or does not increment by 10° each time.

-1 does not perform the correct calcuation in the for loop: 9.0/5.0*celsius + 32

/2
FunctionTemperature Conversion
-1 file not named correctly (i.e. lab5_function_temp_convert.php)

-3 the temperature conversion was not created by a loop performing the calculation (i.e. table of data is hard-coded

-1 loop does not start at -40° celsius and/or does not stop at 100° celsius and/or does not increment by 10° each time.

-1 for loop does not call an appropriately named function that performs and returns the temperature conversion.

-2 no function created for the temperature conversion.

-1 function created for the temperature conversion, but does not work.

/3
Other Penalties
XHTML Valid
-1 no clickable XHTML image provided on lab5*.php pages.

-2 <!DOCTYPE> in header.php was not Strict (used Transitional or HTML 4.01 instead)

-2 more than one XHTML error per page on average in lab5*.php pages.

-1 one or less XHTML error per page on average in lab5*.php pages.
-2

(-1.0 per incident, maximum 2 incidents)

Late Submission
-0 lab submitted on time

5 lab submitted late but within 72 hours of due date

-20 lab not submitted within 72 hours of due date

/5
header.php and footer.php Implementation
-1 no link added to header.php to lab5.php page to make it part of the overall website

-1 per lab5*.php page that does not implement header.php

-1 lab5*.php page that does not implement footer.php files.

-4

(-1.0 per incident, maximum 4 incidents)

# Submission

Publish your pages on the opentech server and submit the URL of your index page as a clickable link in the comment section of the "Assignment 5" drop box in DC Connect. If you do not submit something into DC Connect, your professor will assume you did not complete the assignment, and the late penalties will apply (including 0/20 if the link was not submitted within the 72 hours late period). The onus is on you to ensure your lab instructor knows that you have work to be assessed.

WARNING

Do not mail or attach your files themselves into DC Connect. They must be published onto the opentech server.

Last Updated: 5/24/2019, 6:43:22 AM