On This Page
Overview
During this assignment, you will:
- Collect data using an HTML form
- Send the form data to a PHP script
- Save the data in your project database
- Document your PHP code
^ top
Specifications
This assignment has several parts and you must complete all parts for full credit.
- First make sure you have completed the exercises from lesson 7 and have saved the files using the specified names exactly.
Using the specified file names makes for easier grading.
- Create an HTML form for your project, named
dbform.php, that collects information from users. The page must include (or require) both the files header.php and footer.php from the includes folder.
Using the specified file name makes grading easier. After you turn in the assignment, you can change the name of the page for your final project to any name you like.
- Create a PHP script, named
dbinsert.php, that collects the form data and performs the following:
- Displays the data entered (see the Example Output below)
- Displays all SQL statements used to save data in your database
- Inserts the data into your database (using an INSERT statement)
- Reports the number of rows affected
- Your insertions must create a join between at least two tables of your database by using the primary key of the first insertion as a foreign key of the second insertion. Print or echo the foreign key to your page for verification.
This specification is made so you understand how to store data in two different tables that can be retrieved using a SQL join. Note that if you do not use mysql_insert_id() then you must use LOCK TABLES around the join insertions to prevent the insertion anomalies discussed in lesson 7.3.4.
- Place your code for the start of a page into a file named
header.php in the includes subfolder. This file must contain the following HTML tags at a minimum:
- Opening HTML tag
- Opening and closing head tags
- Opening and closing title tags with the name of your project page enclosed
- Opening body tag
- Place your code for the end of a page into a file named
footer.php in the includes subfolder. This file must contain the following HTML tags at a minimum:
- Closing body tag
- Closing HTML tag
- 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.
- 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:
- Does not contain a SQL 'USE' or 'CREATE DATABASE' statement anywhere in the file
- Includes
DROP TABLE IF EXISTS statements for all tables
Note that phpMyAdmin supports all these behaviors if you select the correct export settings.
- Create a PHP comment at the top of all your PHP pages formatted like the following:
/**
* CIS-165PH Asn 7
* dbentry.php
* Purpose: Processes form data and saves it in
* my project database.
*
* @author Ed Parrish
* @version 1.0 04/05/10
*/
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.
- In your README.txt file provide instructions on using this assignment. For example, if a password is required, please include a password. If any values are required for a form, please provide some example values.
- 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. Also, please do not put any spaces or special characters like #, : or $ in any file or folder names.
Example Input Form (dbform.php)
Example Output (dbinsert.php)
First name: Fred
Last name: Flintrock
Address: 123 Rocky Road
City/Township: Bedrock
State/Province: CA
Zip/Postal Code: 12345
Country: USA
Phone: 555-1234
SQL:
INSERT INTO addresses(Address, City, State, Zip, Country )
VALUES ('123 Rocky Road', 'Bedrock', 'CA', '12345', '555-1234')
Rows affected: 1
SQL:
INSERT INTO customers(LName, FName, AddressID, Phone)
VALUES ('Flintrock', 'Fred', 5, '555-1234')
Rows affected: 1
^ top
Extra Credit
The following are worth extra credit points:
- Read ahead in the textbook and use conditional statements to validate the user input. For instance, display an error message if the user leaves a field blank and stop the insertion script from entering the bad data. (1-2 points depending on difficulty)
- In addition to the above, perform a query on your database to prevent users from re-entering an already existing row of data. (2 points)
Make certain that your README.txt file lists any extra credit attempted.
^ top
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
HTML Code
- 4: Demonstrates mastery of HTML
- Has extra features or demonstrates techniques beyond the assignment
- Meets all specifications (see above) with particularly elegant solutions
- No errors in the HTML code (both opening and closing tags used)
- 3: Has mostly correct HTML code
- Demonstrates many techniques from the lesson
- Meets all specifications (see above)
- May have 1-2 minor HTML errors like missing a closing HTML tags
- 2: Has some of the functionality expected of the assignment
- Demonstrates some techniques from the lesson
- Meets some of the specifications (see above)
- May have 4-5 minor errors
- 1: Serious problems but shows some effort and understanding
- Demonstrates few techniques from the lesson
- Meets few of the of the specifications (see above)
- Has many errors
- 0: No HTML file submitted or page does not display anything
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
^ top
What to Turn In
Submit your assignment following the instructions for homework. Create a single zip file with the following items in the specified folders for grading:
- Place the following files in your webapp root directory:
README.txt file
dbform.php file
dbinsert.php file
- dbname.
sql file
- Place the following files in a subfolder named
includes:
header.php
footer.php
- Add into the webapp root directory the following exercise files from Lesson 7:
main.html
form.php
formecho.php
formdb.php
Note that there is no need to include any exercise files except those listed above.
Please careful of the spelling, including capitalization, as you will lose points for a misspelled name.
Submit a zipped file with all required files in the specified directories following the instructions for homework. Your .zip file must include all the files and subdirectories needed to make your assignment function properly and run without errors or warnings. Do not assume that the instructors has any files except dbconvars.php. Your assignment must work as submitted with the addition of the dbconvars.php file into the includes directory.
^ top
Home
| Blackboard
| Syllabus
| Expectations
| Schedule
Project
| Help
| FAQ's
| HowTo's
| Links
Last Updated: April 15 2012 @19:03:28
|