Total members 10262 | Gratitudes |It is currently Thu May 24, 2012 5:14 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Article
 Article subject: validate e-mail in php
PostPosted: Sun Nov 30, 2008 7:30 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

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:
mailname@domainname.xxx


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 .

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 validate international phone number value
 validate age entered as selection box in javascript
 How to send conformation e-mail through JSP
 validate username
 validate email address in asp
 configure cisco call manager express for voice mail
 mail function problem
 validate mail in jsp
 send mail using php
 validate domain name in php

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Article | Next Article 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team