Practice 6

Main | Review of Operators | Mathematical Functions | Practice 5 | Solution 5 | HTML Forms | PHP Forms | Practice 6 | Solution 6 | PHP and E-mail | Practice 7 | Solution 7

This exercise will build on your knowledge of conditionals and functions, while testing your understanding of the material from our discussion on online forms. To get a better idea of what this application will do, you should interact with it. Go here, and try pressing the "Submit Query" button without entering any information into the boxes above. They try pressing the "Submit Query" after you have entered information.

You should notice that if you leave either the text-box labeled "First Name" or "Last Name" empty, that you see the error:

You did not fill in all the fields, try again

You will be responsible for checking if either box is left empty by using PHP's built-in functions. The variables that we will use to denote what is to go into each text-box respectively are $first and $last.

To complete this exercise you must:

  • Create a file in "public_html/php" called "simpleForm.php".
  • Be sure that "simpleForm.php" is viewable from the web.
  • Fill in "simpleForm.php" with this incomplete code.
  • Complete the PHP section of the incomplete code so that it satisfies the following:
    1. Use isset() to test if the first variable has been set to a value through user interaction.
    2. Use empty() to test if the first or second variable is empty.
    3. Use echo to send an error message to the user telling them that they need to fill in both text-boxes.
    4. Call the show_form() function.


jfulton [at] member.fsf.org
22 Aug 2013