Practice Quiz

PHP Forms Processing

Instructions

This practice quiz is posted to help you prepare for the final exam. The questions here are similar to those that will be on the exam. (Some of them may actually be on the exam.) Mark your selections using the radio buttons. Answers are shown by clicking the button at the bottom of the page.

  1. Which of the following is not the name of an array used to hold data from a form submission to a PHP processor?
    1. $_GET
    2. $_POST
    3. $_REQUEST
    4. $_RESPONSE
  2. To protect a PHP script against an HTML injection attack
    1. it is sufficient to use JavaScript to validate the form data before submission.
    2. one should avoid using the GET method.
    3. it must validate or sanitize data received from a form submission before using it in response content.
    4. the script needs to verify that form submission is coming from a trusted IP address.
  3. If a checkbox in a form is not checked, then when the form is submitted, in the form data received by the form processor, the checkbox form field
    1. is present, but its value is unset
    2. is not present
    3. is present, and its value is FALSE
    4. is present, and its value is "unchecked"
  4. If an HTML form contains a field that allows multiple values, such as a select with the multiple attribute,
    1. using a PHP form processor, there is no way to access values other than the first one.
    2. the field name must end with [] so it becomes an array.
    3. the field name will be repeated in the form data received, occurring one time for each distinct value.
    4. the field data will not be sent when the form is submitted.