*Just a note; this was a subject was one that I was supposed to do for WD2 but out of sheer misreading of the directions I did a summary on another subject. This is such an important concept that I figured that it should not be left out of the summary collections here.
Form validation is extremely important! From a business standpoint it is vital to receive the appropriate information from customers and individuals. It is also a great tool of protection against anyone who will want to enter information into our form to try to sabotage our system. There are two different places to validate the form; client-side and server-side.
Client-side validation happens on the actual web page that is pulled up on the user's browser. We set up java script to read empty spaces or errors depending on additional parameters that we set and we then tell java to return a message back saying that the form is invalid. This will help ward off potential hackers and remind those are the more innocent type to enter correct information; sometimes we may miss the little @ when we are filling in our email.
Here is the actual meat where PHP is involved. What if a hacker is smarter than the java you put in place? Well PHP has the right tool for you because it adds a layer of protection and doubles the security. That doesn't mean it is fool proof but it does mean that there is a less likely chance that someone will get past on shenanigans. What the server-side validation does is runs the error checking that you write with PHP. (Since I know little of java programming it is hard to say I know how to write the commands for error checking. I have picked up quite a bit from this class on PHP.) Here is some error checking validation that helps the server know what to do:
if($_POST['txtfName']=="") {
$errors['fname']='The first name field is empty, please enter your name';
}
This is an example of PHP code for server-side validation which is found on PHP Motors contact page. You will not see the code unfortunately, like most of my example from previous summaries, because it is happening in the background on the server. But you see that the code reads, "If the first name box contains NO value, then send an error message that says that the first name field is empty, please enter your name." These errors can help perform any validating that is necessary for a functioning form.
Here is a test you should try; go to any of PHP Motors forms, the contact page, customer or employee registration and try clicking on the submit button without entering any information and you will see the error messages pop up saying, "Not so fast bucko!" Heck, even try it next time you filling out a form for that car giveaway and you may see some form validation.