1.10 digit contact number: if(preg_match("/^[0-9]{10}$/", "1234567880"))//contact no { echo 'okay'; }else{ echo 'denied'; } 2. Email Address:
if(preg_match("/^([a-zA-Z0-9_-]|\.)+@(([a-z0-9_-])+\.)+[a-z]{2,6}$/", "someone@domain .local"))//email { echo 'okay'; }else{ echo 'denied'; } 3.names:
if(preg_match("/^[a-zA-Z]{2,30}$/", "KK"))//names { echo 'okay'; }else{ echo 'denied'; }
4. Email validation
$email = "someone@domain.local"; if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo "E-mail is not valid"; } else { echo "E-mail is valid"; }
for more referenceshttp://www.php.net/manual/en/function.preg-match.php
http://www.php.net/manual/en/function.filter-var.php
Adios!
No comments:
Post a Comment