Check Mobile Number
You can preg_match()check the 10-digit mobile numbers:
preg_match('/^[0-9]{10}+$/', $mobile)
To call it in a function:
function validate_mobile($mobile)
{
return preg_match('/^[0-9]{10}+$/', $mobile);
}
Email Verification
You can use filter_var()with FILTER_VALIDATE_EMAILto check your email:
$email = test_input($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
To call it in a function:
function validate_email($email)
{
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
However, it filter_varwill return the filtered value on success and falseon failure.
Additional information at http://www.w3schools.com/php/php_form_url_email.asp .
, preg_match() , :
preg_match('/^[A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z.]{2,4}$/', $email)