Make your own free website on Tripod.com

Visit the Official PHP Website

Search this Site

PHP Programming

By James N Hitz

From the Top

We begin by defining a few variables, namely $datafile, $formTop and $formBot.

$datafile indicates the path to the file we will use for saving the addressed, $formTop represents the upper part of the form, and $formBot represents the lower part of the form.

We hereby set $formTop and $formBot for use just in case we want to re-create the form if the user should provide the wrong information. Remember... DON'T TRUST THE USER to do the right thing. Told ya'.

We then validate the email address. Notice here that the method I have used to validate the email address is a lot more thorough than the one in lesson seven. (If you were with me, I'm still waiting for yours. A few people did try but one T. Archibold reaaaaally tried but... He knows the rest of the story.

If the email address supplied is wrong, we create an error message containing a text box (for re-entering) into the variable $outString. If the address is Ok we still recreate it as a HIDDEN input control inside the variable $formOk - just in case the other entries are wrong. This same technique is used when validating the first and last names.

Notice how we append to $formOk and $outString using .= operator [String Concatenation].

If all entries are OK, $outString will be blank and $formOk will be full. So to test whether all entries were OK, we simply test the length of $outString. If it's length is greater than zero, there was an error. We print it and exit.

Let's retreat a bit.

<< Five More Functions | Diving the Code >>

JamHitz Productions