MMDT1146 PHP Programming
Week 9


Week 9

Notes:

  • Security is a concern any time a user can input textual data.

Pythex - Python regular expression editor

Regular Expression repository RegExLib


Lab 9

This lab is to test your knowledge of being able to check user input data for errors and to lessen the possibility of a user entering malicious data.

The lab must contain several items.  Your resulting output should like similar to this.

Modify the pages add.php and edit.php from the previous lab:

  • Eliminate the possibility of a user entering malicious data.  Do this by making a function that strips tags, strips slashes, and removes any whitespace from the ends of the string (trim).  Punctuation will stay for this assignment, as names and addresses have punctuation in them.. 
  • Check user input.  Use regular expressions to do this.
  • If the input does not pass the regular expression, create an error message stating this and do NOT add the record to your database.
  • If the input did not pass, when the screen reloads, keep the original data in the textboxes so the user does not have to type everything back in.

Assignment is due 1 week from when it was assigned.  50% penalty if late.

MMDT 1146 Lab 9
Grading Criteria
Date
Possible
Points
15
Your
Points
15
General function to strip tags, slashes, trim, etc. 3 3
Validate firstname and lastname fields using a regular expression.
(add.php, edit.php)
2 2
Valide the state field using a regular expression.  Must be the standard capitalized 2 character state code.
(add.php, edit.php)
2 2
Valide the phone numbers using a regular expression.  The choice is yours to use 123-456-7890 or (123) 456-7890 format.
(add.php, edit.php)
2 2
Valide the email field using a regular expression.
(add.php, edit.php)
2 2
Display error message(s) if  validation(s) does not pass.
(add.php, edit.php)
2 2
If validations does not pass, original data is kept and user is able to make corrections and resubmit.
(add.php, edit.php)
2 2