Total members 11894 |It is currently Thu Nov 21, 2024 5:35 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





if you have a form for user registration and you want to check the user mail ,if it valid or not ,it is easy just use the following check .
Note : the check here is based one the "Regular Expression"
Code:

<?php
if (eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email))
{
   return
FALSE;
}

?>

or put it in php function
Code:
<?php
function checkmail($email){
    return
eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
}


Above , i didn't check the domain name ! . you just checked expression
Code:


so programmer make more checking , by checking on the domain name if it valid or not , below you can see an example for this .

Code:
<?php
list($mailusername, $Domainname) = split("@",$myemail);
if(
getmxrr($Domainname, $MXHost))
{
   return
TRUE;
}
else
{
   if(
fsockopen($Domainname, 25, $errno, $errstr, 30))
   {
      return
TRUE;
   }
   else
   {
      return
FALSE;
   }
}
?>

the function getmxrr(...) and fsockopen(...) are built in functions in php library .



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : validate e-mail in php
 validate mail in jsp     -  
 validate username     -  
 validate domain name in php     -  
 validate email address in asp     -  
 validate international phone number value     -  
 validate age entered as selection box in javascript     -  
 how to send mail with Ant     -  
 send mail using php     -  
 send mail cc and bcc in php     -  
 Help Sending e-mail from VB.Net application     -  



Topic Tags

PHP Validation
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com