www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-21-2009, 09:32 PM
    semiNoob0820 semiNoob0820 is offline
    Registered User
     
    Join Date: Feb 2009
    Location: Chicago
    Posts: 24
    PHP email validation...

    I have seen many different ways to validate email addresses using PHP. There are many different approaches to this, but I want to implement the best one (I know PHP should be VERY thorough and client-side check be brief). I am confused as to which one out of the ones I have read about (PHP) is the best AND most thorough. Can someone please direct me to a site that has the best PHP email validation? Or can someone just send me the code directly please. Thanks in advance .
    Reply With Quote
      #2  
    Old 11-21-2009, 10:10 PM
    JavaServlet JavaServlet is offline
    Registered User
     
    Join Date: Jun 2009
    Posts: 92
    Quote:
    Originally Posted by semiNoob0820 View Post
    I have seen many different ways to validate email addresses using PHP. There are many different approaches to this, but I want to implement the best one (I know PHP should be VERY thorough and client-side check be brief). I am confused as to which one out of the ones I have read about (PHP) is the best AND most thorough. Can someone please direct me to a site that has the best PHP email validation? Or can someone just send me the code directly please. Thanks in advance .
    Here is one way of doing it using eregi function:
    Code:
    if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){ 
       return FALSE;
    }
    Reply With Quote
      #3  
    Old 11-21-2009, 11:31 PM
    NogDog's Avatar
    NogDog NogDog is offline
    High Energy Magic Dept.
     
    Join Date: Aug 2004
    Location: Ankh-Morpork
    Posts: 14,009
    If you are talking about verifying that the format is valid, the most thorough implementation I've seen is at http://www.iamcal.com/publish/articl...parsing_email/ (and the least likely not to give false negatives). If you are talking about verifying that it is an actual email address, the only foolproof way I know of is to send an email to it (such as is done when you sign up for a forum like this one and you have to click on a confirmation link).
    __________________
    "That's what the gods are! An answer that will do! Because there's food to be caught and babies to be born and life to be lived and so there is not time for big, complicated, and worrying answers! Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." -- from Nation, by Terry Pratchett
    freelancer.internet.com
    Email me
    Reply With Quote
      #4  
    Old 11-22-2009, 11:30 AM
    semiNoob0820 semiNoob0820 is offline
    Registered User
     
    Join Date: Feb 2009
    Location: Chicago
    Posts: 24
    ahhh k... thanks... didn't know that the ONLY way to make sure email address EXISTS is to send it FIRST...
    Reply With Quote
      #5  
    Old 11-22-2009, 12:59 PM
    NogDog's Avatar
    NogDog NogDog is offline
    High Energy Magic Dept.
     
    Join Date: Aug 2004
    Location: Ankh-Morpork
    Posts: 14,009
    Quote:
    Originally Posted by semiNoob0820 View Post
    ahhh k... thanks... didn't know that the ONLY way to make sure email address EXISTS is to send it FIRST...
    There are ways to poll mail servers to verify an address, but you cannot count on them to always work, as not every mail server is configured to respond (for privacy or security reasons, for instance), and even if it is, there's always a possibility it could be temporarily down (or the network connection to it).
    __________________
    "That's what the gods are! An answer that will do! Because there's food to be caught and babies to be born and life to be lived and so there is not time for big, complicated, and worrying answers! Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." -- from Nation, by Terry Pratchett
    freelancer.internet.com
    Email me
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 04:13 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.