Validation of form play an important role while you are working on a live project. Validation is very important for the registration form so that the user get restricted of entering wrong details or from anti programmed.
If any user get succeed in doing anti programming then he may thief your data or this program may crash your database or your site may get hacked. For this we need to restrict the user from entering special character in the input field. So validation of form from unwanted entry is very important, so let's see how to validate form.
At first we will write all the HTML input field, radio button, dropdown list, checkbox etc and a submit button to collect all the filled data.
HTML CODE
Now see below how to validate all this field in php
PHP CODE
Explanation :-
Line 4 to 14 :- Storing the form data value in variables and checking for special character enter in the text field by the users or by hackers to avoid from anti programming or data thief by creating a check function.
Line 12 :- Used of implode function to provide comma between the two array value.
Line 16 to 44 :- Validating Date from entering wrong date of birth. And checking for leap year.
Line 47 to 107 :- Checking all the fields are be filled by the user or not.
Line 119 to 132 :- Working functionality or check function and displaying error message.
No comments:
Post a Comment