SitePoint Sponsor

User Tag List

Page 3 of 4 FirstFirst 1234 LastLast
Results 51 to 75 of 77
  1. #51
    SitePoint Enthusiast z00om's Avatar
    Join Date
    Dec 2001
    Location
    California
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its because vB keeps steeling my backslashes!!!!

    The reg statement I took from a post above...

    gethostbyaddress-ie: 127.0.0.1
    gethostbyname-ie: www.host.com

    I didn't know of their inefficency, so, I guess they should be cut out... anyway, it was just the first actual function that could be used.(sort of)
    [z00om : home]
    [z00om@hotmail.com]
    [z00om : aim]
    [77968493 : icq]

  2. #52
    SitePoint Evangelist =X='s Avatar
    Join Date
    Jun 2001
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have any of you guys thought about the .info domains...?

    seems like a lot of functions above only allow 2 or 3 characters in the tld...
    PHP-Webservices - Profesional Hosting and Programming of sites.

  3. #53
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After reading this thread and wanting anyone with a valid email address and due to the developing variety of email address configurations, I have decided to do away with a regex for email and just have the user enter their email twice, like a password validation.

    John
    John

  4. #54
    SitePoint Zealot
    Join Date
    May 2001
    Location
    UK
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know these regx are not perfect, but are very cleaver. If the only validation you have is checking both the user inputs are the same they could just enter "." in both?
    I belive the following edits freddy's script to work with .info as suggested by =X=

    PHP Code:
    function checkEmail($email) {
        
    $emailCheck false;
        if(
    preg_match("/^([A-Z0-9\.\-_]+)@([A-Z0-9\.\-_]+)?([\.]{1})([A-Z0-9\-_]{2,3,4})$/i"
    $email$matches)) {
            
    $emailCheck true;
            }
        return 
    $emailCheck;
        }

    print 
    checkEmail('freddy.rules@foobar.com') ? 'Email Good' 'Email Bad'

  5. #55
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how about .museum ?

  6. #56
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I though it was .mus not .museum

    Edit: Confirming it is .museum
    Last edited by petesmc; Dec 16, 2002 at 03:03.

  7. #57
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    four letter domains endings are getting quite common nowadays. 'aero' 'coop' 'info' 'name' etc. The we have 'museum' and we should not forget braced IP# emails.

    blartfast@someold.museum
    blartfast@[127.0.0.1]

    As fsid does, getting the surfer to activate their account by clicking a link in the email you send them is probably the most accurate validation in the end

    On a subnote: A nice regex resource site is http://www.regxlib.com/
    -- yeah, it's asp based and you'd need to sling "/ <and> /i" around any you borrowed. Useful tho.
    teckis - that's news to me.

  8. #58
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by MPK
    I know these regx are not perfect, but are very cleaver. If the only validation you have is checking both the user inputs are the same they could just enter "." in both?
    I belive the following edits freddy's script to work with .info as suggested by =X=

    PHP Code:
    function checkEmail($email) {
        
    $emailCheck false;
        if(
    preg_match("/^([A-Z0-9\.\-_]+)@([A-Z0-9\.\-_]+)?([\.]{1})([A-Z0-9\-_]{2,3,4})$/i"
    $email$matches)) {
            
    $emailCheck true;
            }
        return 
    $emailCheck;
        }

    print 
    checkEmail('freddy.rules@foobar.com') ? 'Email Good' 'Email Bad'
    So is the above ok so far (except .museum) ?
    Thanks,
    John

  9. #59
    And your point is.... redgoals's Avatar
    Join Date
    Feb 2002
    Location
    Birmingham, UK
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    just change 2,3,4 to 2,6 should work for .museum i think.
    Last edited by redgoals; Dec 28, 2002 at 14:48.
    http://redgoals.com ... my site ... nuff said

  10. #60
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php

    $emails 
    = array(
    'john@domain.com',
    'john.smith@domain.com',
    'john.smith@domain.netcom.com',
    'john.smith@domain.co.uk',
    'john.smith@domain.com.au',
    'john.smith@domain.to',
    'smith@subdomain.domain.to',
    'smith@domain.to',
    'john@some-domain.com',
    'christopher.padfield@new.ox.ac.uk'
    'john_smith@some_domain.com',
    'john_smith@some-domain.com',
    'john@domain....com',
    'john_smith@_domain.tld',
    'smith@_subdomain.domain.tld',
    'smith@sub_domain.domain.tld',
    'foo@bar',
    'foo@bar.b',
    'tom.o\\'leary@foo.bar',
    '
    foo@foobar',
    '
    foo @bar.tld',
    '
    @bar.tld',
    '
    foo@bar.info',
    '
    foo@bar.museum'
    );

    foreach ($emails as $e) {
    $searchstring = '
    /^([_a-zA-Z0-9-/\']+(\.[_a-zA-Z0-9-/\']+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4}))/si';
    if (
    strpos($e"@" )) {
    if(
    preg_match($searchstring$e)) {
    print 
    'True';
    }
    else {
    print 
    'False';
    }
    }
    else {
    print 
    'False';
    }
    print 
    ' - ' $e '<br>';
    }
    ?>
    gives:
    Code:
    True - john@domain.com
    True - john.smith@domain.com
    True - john.smith@domain.netcom.com
    True - john.smith@domain.co.uk
    True - john.smith@domain.com.au
    True - john.smith@domain.to
    True - smith@subdomain.domain.to
    True - smith@domain.to
    True - john@some-domain.com
    True - christopher.padfield@new.ox.ac.uk
    False - john_smith@some_domain.com
    True - john_smith@some-domain.com
    False - john@domain....com
    False - john_smith@_domain.tld
    False - smith@_subdomain.domain.tld
    False - smith@sub_domain.domain.tld
    False - foo@bar
    False - foo@bar.b
    True - tom.o'leary@foo.bar
    False - foo@foobar
    False - foo @bar.tld
    False - @bar.tld
    True - foo@bar.info
    True - foo@bar.museum
    Last edited by Add; Mar 31, 2003 at 14:13.

  11. #61
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the 's in the expression should be escaped with a \
    Last edited by Add; Dec 29, 2002 at 06:16.

  12. #62
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So should it be:

    Code:
    // Added a \
    $searchstring = '/^([_a-zA-Z0-9-/\\']+(.[_a-zA-Z0-9-/\\']+)*@[a-zA-Z0-9-]+(.[a-zA-Z0-9-]+)*(.[a-zA-Z]{2,4}))/si';
    ???

    -Peter

  13. #63
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no, remove the / from infront of the \ - the \ is to escape the '

    or just do this...

    PHP Code:
    $searchstring "/^([_a-zA-Z0-9-']+(\.[_a-zA-Z0-9-']+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4}))/si"
    (no backlsash required)
    Last edited by Add; Dec 29, 2002 at 06:25.

  14. #64
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to let you know, you're code doesn't work properly. Partly because you the single quotes aren't escaped but also, you get an Unknown Modifier on the Preg_match line with the single quote.

    EDIT: Sorry, didn't realise you have to remove the /s before the 's

  15. #65
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by petesmc
    Just to let you know, you're code doesn't work properly. Partly because you the single quotes aren't escaped but also, you get an Unknown Modifier on the Preg_match line with the single quote.
    i beg to differ - http://add.no-ip.com/emailtest.php & http://add.no-ip.com/emailtest.phps

    the single quotes are escaped, that's what the missing backslashes are for...

  16. #66
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lol, we're both editing our posts at the same time, confusing each other. Anyway, got it working, nice regexp!

  17. #67
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  18. #68
    Fully Qualified Fool :) luke-innovative's Avatar
    Join Date
    Jun 2002
    Location
    Kent, UK
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just wanted to say cheers guys, your code helped me (and I'm sure other people) loads

    Cheers
    Luke
    Luke-Martin.com (work in progress) :: Independent Web Designer's Portal
    Freelance Forums :: Sign Up Here
    "What happens if you get scared half to death twice?"

  19. #69
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    So what was the final RE to use for email addresses?

    Thanks.

    Mak

  20. #70
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $searchstring "/^([_a-zA-Z0-9-']+(\.[_a-zA-Z0-9-']+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4}))/si"
    pretty cool, unfortunately doesn't work with an ip within the email-address, e.g. tom@123.129.67.12
    Does anyone has a clue how to include this?
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  21. #71
    SitePoint Addict MarekS's Avatar
    Join Date
    Jan 2003
    Location
    Estonia / Tallinn
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I must be doing smth wrong, but this does not work on my machine?

    Code:
    $pattern = "/^([_a-zA-Z0-9-']+(\.[_a-zA-Z0-9-']+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4}))/si";
    
    if (preg_match($pattern, $email)) {
    	echo '1';
    } else {
    	echo '0';
    }
    thanks,

  22. #72
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MarekS
    but this does not work on my machine?
    if you could be a little more precise with 'does not work'.
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  23. #73
    SitePoint Addict MarekS's Avatar
    Join Date
    Jan 2003
    Location
    Estonia / Tallinn
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah sry, here it is:

    Code:
    <?php
    function isValidEmail($email)
    {
    	$email = trim($email);
    	
    	$pattern = "/^([_a-zA-Z0-9-']+(\.[_a-zA-Z0-9-']+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4}))/si";
    	
    	if (preg_match($pattern, $email)) {
    		echo 'valid';
    	} else {
    		echo 'bad';
    	}
    }
    
    // test
    echo isValidEmail('abc@cde.com'),'<br />'; // valid
    echo isValidEmail('abc@cde.comXXXXXXXXXXXXXXXX'),'<br />'; // valid
    echo isValidEmail('abc@c.de-_!"#.%&/];:*'),'<br />'; // valid
    ?>

  24. #74
    SitePoint Wizard Dangermouse's Avatar
    Join Date
    Oct 2003
    Posts
    1,024
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use this if it helps anyone
    PHP Code:
    function check_email ($email) {
       if (
    preg_match("#^[a-z0-9_-]+(?:\.[a-z0-9_-]+)*@([a-z0-9-]+((\.[a-z0-9-]+)*(\.[a-z]{2,4})))$#i"$email$host)) {
          if (
    checkdnsrr ($host[1]) AND (gethostbyname($host[1]) != $host[1])) {
             
    getmxrr ($host[1], $mx);
             if (
    $mx[0])
                return 
    true;
          }
       }
       return 
    false;


  25. #75
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dangermouse
    PHP Code:
     [...] (\.[a-z]{2,4})))$#i", $email, $host)) 
    here you should use {2,6} to fit the existing TLD's
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •