In this article you’ll construct and validate a simple form using HTML and PHP.
The form is created using HTML and validation and processing of the form’s contents is done with PHP.
The loop would generate the HTML for the options on the fly, and the check if the option has been selected or not can be incorporated into it. It’s just one of those minor inconsistencies we have to live with.
One topic which I have not addressed and is outside the scope of this article is what you would do with the data after validation is successful.
This prevents the form from breaking if the user submits HTML markup and also is a means of protecting against XSS (Cross Site Scripting) attacks, which attackers will use to try to exploit vulnerabilities in web applications.
Now that you’ve defined the form in HTML, let’s identify the two stages the form goes through – when the blank form is loaded, and when the user has completed the form and clicks the submit button.
Next determine whether the form has been submitted by checking how the page was requested.
If the form has just been requested, then the is outputted as part of the element’s HTML. It is actually a better idea to restructure the code as a loop than to blindly add code to check each option manually.
He's also written a book about Dreamweaver CS3 for Hodder Education.
This article discusses how to validate information you get from users — that is, to make sure that users enter valid information in HTML forms in an ASP. What you'll learn: If you ask users to enter information in a page — for example, into a form — it's important to make sure that the values that they enter are valid.