The easiest and safest way to check whether an email address is well-formed is to use PHP's filter_var() function.
In the previous chapter, all input fields were optional.
This perimeter protects the core business logic, processing and output generation.
Beyond the perimeter is everything considered potential enemy territory which is...literally everything other than the literal code executed by the current request.
For example, the input should not be empty, should be less than 25 chars, should be alpha-numeric, etc You can associate a set of validation descriptors for each input field in the form.
Required field will check whether the field is filled or not in the proper way.
We will cover a few samples like validating e-mail address and URLs later. Here we will name it check_input and simply call this function whenever we need to validate simple input data: Note the check_input function at the bottom.There are two types of validation are available in PHP.Such code can now do no harm and is safe to be displayed on a page or inside an e-mail. if quotes are escaped with a slash \ let's remove that.Most of cases we will use the * symbol for required field.Validation means check the input submitted by the user.