email validation

  • 14 years ago
    hi, please help.
    this seems to be working at first but later on, it sometimes selects email..which means that sometimes it accepts, sometimes not...

    if(!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/",$email){
        echo "Invalid email";
    }

    any suggestions? comments? thanks...










  • 14 years ago

    hi,

     you want to check whether the email id is valid or not, right.

    if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email))
       {
          echo "Invalid email id";

       }

    try this piece of code..

    Regards

    sarvesh

  • 14 years ago

    i'll try that... thanks!!!!






  • 14 years ago
    Hi, check this

    if(!ereg("[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]", $email)){
          return FALSE;
       }
       else {
          return TRUE;
       }






Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only two kinds of languages: the ones people complain about and the ones nobody uses” - Bjarne Stroustrup