Hi all,
In this article we will learn How to Validate Forms Using PHP. The server side form validation is very secure and useful in php code. We implement the form validation in php for registration to site or signup something like that. In the form validation, check input given by the user is correct or wrong. We check some useful form validation like:
- Numbers only
- Characters only
- Email Address
- Empty value
- Input Length
Numbers Only
In form validation, is_numeric() helps to check input given by the user is only numbers or not. First we save the user input value to a variable. After that, we check the input values are numbers or not. If the enter values in not number then errror message will display.
OR
In here we can add only numbers
Characters Only
In form validation, ctype_alpha() helps to check input given by the user is only letters or not. First we save the user input value to a variable. After that, we check the input values are letters or not. If the enter values is not characters then errror message will display.
OR
Email Address
Check the input email address are valid or not. If the enter email address is not valid email then error message will display.
OR
Empty Value
Check input value is empty or not. The empty() function helps to check the field is empty or not.
Input Length
The strlen() helps to calculate string length in PHP.
Full Code
Server Side Form validations Using PHP-Prittytimes
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.