A10-Classy Forms

On This Page


Overview

During this assignment, you will:

  • Write functions for the FormVerifier class and use the class for writing a single-page form.

Note to Mac Users: PHP does not seem to like Mac end of lines character ("\r"). So make sure you choose the option that uses the *nix end of line character ("\n") in your text editor before turning in an assignment. For instructions on settings for various text editors, see John Govsky's page: Text Editors for HTML and Script Editing

Specifications

This assignment has several parts and you must complete all parts for full credit.

  1. First make sure you have completed the exercises from lesson 10 and have saved the files using the specified names exactly. Using the specified file names makes for easier grading.
  2. Update the FormVerifier.php class to add at least two additional verification functions such as:
    • isNotAlpha($field, $msg)
    • isNotFloat($field, $msg)
    • isTooLong($field, $msg, $max)
    • isTooShort($field, $msg, $min)

    List the names of the new functions in your README.txt file so I can find them easily. You will probably want to make use of the type-checking and conversion functions of PHP in your verification functions.

  3. The name of the FormVerifier class file must be formverifier.php and be placed in the includes directory. If you use the FormLib class then save it in a file named formlib.php and place it in the includes directory as well.
  4. Write a single-page form named form.php that uses your updated FormVerifier class and your new functions. Note that using FormLib uses the FormVerifier class.

    You may use the same form page as you used in previous assignments, or you may choose a new page.

  5. Your form.php page and must include the following:
    1. A main() function that controls the logic of the page and calls the checkForm(), processData() and showContent() functions.
    2. A checkForm() function that verifies the values entered by the user and creates error messages for any problems found.
    3. A processData() function that does something with the form data including accessing the database using the form data as part of a SQL query.
    4. A showContent() function that displays the form.

    You may have as many additional functions as you like, either embedded in the page or in an include file. However, you may NOT change the names of the above functions or move them to another file.

  6. Ensure that user entries are checked for errors, errors are clearly identified and that users can correct mistakes easily.
  7. Use the included file includes/dbconvars.php for all database connections in your code.

    Even though you do not need to submit your dbconvars.php file, the instructor will use one to test your work. Failure to use a dbconvars.php file will result in a poor grade.

  8. Export (dump) your database as SQL statements to a text file using the technique we discussed in lesson 2.1.5. Name your file after your database name and add the extension .sql to the name (dbname.sql). For example, the artzy database export file would be named artzy.sql.

    Make sure that your dbname.sql file:

    1. Does not contain a SQL 'USE' or 'CREATE DATABASE' statement anywhere in the file
    2. Includes DROP TABLE IF EXISTS statements for all tables
  9. Create a PHP comment at the top of all your PHP pages formatted like the following:
    /**
    * CIS-165PH  Asn 10
    * form.php
    * Purpose: data-entry form
    *
    * @author Ed Parrish
    * @version 1.0 4/15/07
    */
    

    Remember that PHP comments must be enclosed within PHP tags. You will get no credit for this part of the assignment if you use HTML comments. For more information on documenting PHP code, see: How To Document PHP Code.

  10. In your README.txt file provide instructions on using this assignment. For example, if a password is required, please include a password. If any particular values are required for a form, please provide the values.
  11. Zip your files and submit the zipped archive file to Blackboard as explained in the section of this document: What to Turn In.

    Note: Please do not turn in more than one *.sql file or I may grade using the wrong file.

Hints and Cautions

  1. Start your assignment by following the steps in exercise 10.2 but adapted to using a form for your project.
  2. Caution: Make sure you have formverifier.php in the includes subdirectory and do not have extra copies in the same directory as form.php. Otherwise changes in formverifier.php in the includes directory may not be detected.

Extra Credit

The following are worth extra credit points:

  1. Use FormLib to construct your form. Make sure you put formlib.php in the includes directory if you use it. (1 point)
  2. Write and use additional validation functions beyond those required. You must use the additional functions to verify your form to receive any extra credit points. (1 point each, 2 points maximum)

Make certain that your README.txt file lists any extra credit attempted.

Grading Criteria

The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.

Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

For information on grading policies, including interpretation of scores, see the course information page.

Lesson Exercises

  • 2: All lesson exercises attempted and turned in
  • 1: Some lesson exercises completed and turned in
  • 0: No lesson exercises completed or turned in

Database Export

  • 2: Database loads from dbname.sql file with no errors or warnings
  • 1: Database loads from dbname.sql file but has errors, warnings or missing data
  • 0: Does not load or dbname.sql file not submitted

PHP Functionality

  • 10: Demonstrates mastery of the assignment
    • Has extra features or demonstrates techniques beyond the assignment
    • Applies concepts from the lesson(s) appropriately
    • Meets all specifications (see above) with particularly elegant solutions
    • No errors encountered during operation
  • 8: Has all the functionality expected of the assignment
    • Demonstrates many techniques from the lesson
    • Meets all specifications (see above)
    • Implementation seems more complicated than necessary.
    • May have one minor error
  • 6: Has most of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets all but one of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have 2-3 minor errors
  • 4: Has some of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets at least 1/2 of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have more than 3 minor errors
  • 2: Serious functional problems but shows some effort and understanding
    • Meets less than 1/2 of the of the specifications (see above)
    • Has a major error or many minor errors
    • Implementation seems very convoluted
    • Demonstrates few techniques from the lesson
  • 0: Does not execute

User-Input Error Handling

  • 4: Errors are handled gracefully and users can correct them easily
    • All input is thoroughly checked
    • Error messages clearly explain how to fix the problem
    • All errors are identified in the form at one time
    • All prior entries retained
    • Errors color-coded or highlighted
  • 3: Errors can be corrected with some effort
    • All input is checked but some minor conditions were missed
    • Error messages somewhat explain how to fix the problem
    • All errors are identified in the form at one time
    • All prior entries retained
  • 2: Errors are tiresome to correct or messages are annoying
    • All input is checked but many conditions were missed
    • Error messages are somewhat vague
    • Only one error at a time is identified
    • Prior entries are discarded
  • 1: Error checking is inconsistent
    • Some input is not checked
    • Error messages are confusing
    • Prior entries are discarded
  • 0: Does not run

PHP Documentation

  • 2: Code is well-documented
    • Name, date, and page description in page comment block
    • Follows format for page comment block
    • Proper use of whitespace and indenting
    • Files are correctly zipped
  • 1: Code has minor documentation errors
    • Has 1-2 documentation errors
  • 0: No apparent attempt at documentation

README.txt File

  • 2: README.txt file submitted with specified information included
  • 1: README.txt submitted but some information was not included
  • 0: No README.txt submitted

Maximum Score: 22, plus extra credit

What to Turn In

Submit your assignment following the instructions for homework. Create a single zip file with at least the following files in the web-application root folder:

  1. README.txt file
  2. All the exercise files from Lesson 10
  3. form.php file
  4. formverifier.php file in the includes directory
  5. formlib.php file in the includes directory, if you use formlib.php
  6. All the other files needed to make your form.php page function
  7. dbname.sql file

Note: if you turn in a file with the wrong file name, you may receive no credit.

Your .zip file must include all the files and subdirectories needed to make your assignment function properly. Do not assume that the instructors has any files except dbconvars.php. Your assignment must work as submitted.

Home | Blackboard | Syllabus | Expectations | Schedule
Project | Help | FAQ's | HowTo's | Links
Last Updated: April 26 2010 @16:42:21