SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    VICTORY IS MINE! luchazard's Avatar
    Join Date
    May 2001
    Location
    USA
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is the php code to make sure an email is in the correct format??

    I want to make sure the user types his/her email address corectly in a form like this...
    PHP Code:
    if ($from_email is wrong); {

    echo(
    "Your email address is incorrectly formatted!");


    Anyone know? I want to make sure its in the correct format like user@domain.com thanks in advance!

  2. #2
    SitePoint Addict lveale's Avatar
    Join Date
    Jun 2001
    Location
    Dublin
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    regular expressions

    Here's a function I wrote.




    PHP Code:
    function is_email_valid($email){


       if(
    eregi("^[a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+\.)+([a-zA-Z]){2,3}$"$email)) 

          return 
    TRUE

       else 

          return 
    FALSE

    If you want to go even further try http://www.thewebmasters.net/php/Validator.phtml

  3. #3
    VICTORY IS MINE! luchazard's Avatar
    Join Date
    May 2001
    Location
    USA
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

  4. #4
    VICTORY IS MINE! luchazard's Avatar
    Join Date
    May 2001
    Location
    USA
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but are you sure that is the standard? Like if someone typed in www.bob@domain.com it would reject it I want everything covered... there must be a standard given by php.net that shows exactly the right way...

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    VICTORY IS MINE! luchazard's Avatar
    Join Date
    May 2001
    Location
    USA
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks freddy!


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
  •