Practice 10
Main | Arrays | Practice 8 | Solution 8 | Associative Arrays | Practice 9 | Solution 9 | Regular Expressions | Practice 10 | Solution 10 | More Regular Expressions | Practice 11 | Solution 11 This practice will build on the ideas that we used to create online forms. In our previous examples we checked if the user forget to fill out a part of our form by using the function empty. In this example we will also check if the user filled in data that is reasonable from syntactical point of view. Here is the form that you will be creating for this exercise. Everything about this form is done for you except function check_input() which you must implement. Within check_input() there is a call to the function url_good() which has already been done for you. If you have a look at it you can see that it uses a regular expression to capture the general properties of any URL. You should use ereg to check for a valid email address and a valid date and then append to the error string if necessary. Email AddressCreating a regular expression to capture an email address will require the user of qunatifiers and the specification of correct address. Here is some guidance to help you:
DateIn this case a valid date has this format: YYYY-MM-DD Such that today's date would be
This date format is what MySQL expects as its default date so checking for this type of date format if you are using PHP with MySQL. RequirementsTo complete this exercise you must:
Note that there are a lot of functions in the sample code, but you only need to find and complete the function check_input() assume that the rest of the code works.
jfulton [at] member.fsf.org
|