Hi all,

I'm trying to write a function to validate the format of an email address. If the function returns 1, it's valid, 0 and it's invalid (1/true & 0/false).

Here's what I have, but it ALWAYS returns 0/false...

function verify_email($input) {
	return eregi("^[a-z0-9\-\.]+\.[a-zA-Z]{2,4}(:[a-z0-9]*)?/?([a-z0-9\-\._\?\,\'/\\\+&%\$#\=~])*$", $input);
}

Any ideas?

Thanks
Max

    [man]eregi[/man] - read the user comments your function is already there

      Already checked. Tried a couple of things there and couldn't seem to make it work. From what I read there I came up with the code I posted, but that doesn't seem to work either.

      Any ideas?

        This is the regex I always use

        <?php
        $regex =
          '^'.
          '[_a-z0-9-]+'.        /* One or more underscore, alphanumeric, 
                                   or hyphen charactures. */
          '(\.[_a-z0-9-]+)*'.  /* Followed by zero or more sets consisting 
                                   of a period and one or more underscore, 
                                   alphanumeric, or hyphen charactures. */
          '@'.                  /* Followed by an "at" characture. */
          '[a-z0-9-]+'.        /* Followed by one or more alphanumeric 
                                   or hyphen charactures. */
          '(\.[a-z0-9-]{2,})+'. /* Followed by one or more sets consisting 
                                   of a period and two or more alphanumeric 
                                   or hyphen charactures. */
          '$';
        ?>

        It works like a dream.

          There are domains like möbel.com and teléfono.it. I think the script would not accept them...

          Fox

            Originally posted by foxroberts
            There are domains like möbel.com and teléfono.it. I think the script would not accept them...

            Fox

            Oh geez, who's gone and broken the domain name standard?! :mad:

              Originally posted by Weedpacket
              Oh geez, who's gone and broken the domain name standard?! :mad:

              I think someone is assuming instead of checking

                Fox... it's mobel.com and telefono.it
                DNS requirements dictate the use of english characters, regardless of the country of origin... The specific domain may show the foreign characters on their webpages, but the domains themselves use enlish characters...

                  For those who don't believe in Fox:

                  [URL=http://www.möbel.com]www.möbel.com[/URL]
                  [URL=http://www.rené.com/]www.rené.com[/URL]
                  [URL=http://www.fôx.com/]www.fôx.com[/URL]
                  and so on...

                  By the way: How to check those?

                  Fox

                    Someone should report them to ICANN which would remove their names from the DNS.

                      Originally posted by foxroberts
                      For those who don't believe in Fox:

                      For those who refer to themselves in third person...

                      "Jimmy shoots, Jimmy scores!" (Ala Seinfeld)

                        Write a Reply...