validate email using php

 Question:

Hi,

I have to validate email in PHP. What is the regular expression syntax for doing this?


Thanks
 





 Answers:
 
You can use ieregi regular expression to validate email address:


Code:

<?
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-
]+)*(\.[a-z]{2,3})$", $mailvar) {
  echo "not a valid mail";
}
?>



Commentaires

Posts les plus consultés de ce blog

XAJAX with PHP – The future of web development

XAJAX with PHP – The future of web development

Database connection pooling in ADO.Net