Form validation is one of the most important parts of a website, in this tutorial you’ll learn how to validate a form and how to display error messages with the form.
Author: BrainBell
Preselecting Multiple Selection Lists
Learn how to use the <select>, <optgroup>, and <option> tags to create a single or multiple selection dropdown list. You’ll also learn how to use the “selected” attribute to preselect options in the select tag.
Preselecting Check Boxes
Let’s see how to return checked (or selected) checkboxes upon submitting a form. You’ll learn how to process individual or group (array) checkboxes with PHP.
Preselecting Radio Buttons
When submitting a form to the server, the value of the selected radio button is passed to the server. Compare that value, if it fits, print out “checked” to preselect that radio button.
Prefilling Text Fields
Learn how to fill fields with the submitted data. For example, when the password is wrong or the username is already taken. You’ll also learn techniques to prefill form by retrieving data from cookies that you saved in cookies on successful submission of the form.
Using Form Elements
Form elements are used for capturing user input. A form contains one or more elements, which are the fields where the user can enter data. When a user finishes entering the data, the form is submitted to the server for verification or storing of the data.
Passing Data with the HTML Forms
Both the GET and POST methods send data to the server, but which method should you use?
Passing User Data
In this tutorial, we discuss how to pass user data from a web browser to a PHP script. You will see how HTTP requests can include user data by creating URLs and embedding links in HTML documents.
Validating Age and Date of Birth
Dates of birth are commonly entered by users. Most dates require checks to see if the date is valid and also if it’s in a required range. In this tutorial, we’ll create a PHP script that validates the given date of birth to check whether it’s in a valid range.
Autoloading Classes
The PHP autoloading feature allows you to load class files automatically in your program. PHP calls an autoloader function when you reference a class, and the autoloader function tries to figure out which file that class is in.