SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ereg not working

    hey.
    I'm using the following pattern to detect if a string is in the correct format of an email address and doesnt contain more than 50 characters:

    Code:
    $email=$_POST['email'];
    $pattern="^[a-zA-Z0-9._-]{1,25}+@[a-zA-z0-9._-]{2,10}+\.[a-zA-Z]{2,4}$"; 
    if (! ereg($pattern,$email)) {
    //code
    }
    But now it keeps giving me errors even if my email address is written correctly.At first I didnt have the maximum characters detection in the script and it worked fine but it doesnt work ever since I added that.Can you tell me how to correct it?

  2. #2
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It gives me the following error when I attempt to run the script:

    Warning: ereg() [function.ereg]: REG_BADRPT: in **********

  3. #3
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can anyone please reply?I really need to get this done soon.......

  4. #4
    SitePoint Zealot devscripts's Avatar
    Join Date
    Sep 2004
    Location
    ur monitor
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hold on trying to find answers for you.
    "None of you [truly] believes until he wishes for his brother what he wishes for himself." By The one and Only Prophet Mohammed (Peace and blessings be upon him)

  5. #5
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh lol,sorry for being impatient

  6. #6
    SitePoint Zealot devscripts's Avatar
    Join Date
    Sep 2004
    Location
    ur monitor
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its ok. while im trying to make u wot u want... please take a look at
    http://www.regexlib.com/Search.aspx?k=email
    "None of you [truly] believes until he wishes for his brother what he wishes for himself." By The one and Only Prophet Mohammed (Peace and blessings be upon him)

  7. #7
    SitePoint Zealot devscripts's Avatar
    Join Date
    Sep 2004
    Location
    ur monitor
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i find this one to be good and then you can use some other identifier to make it see if its no more than 50 characters

    n:

    ^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$


    Description: This expression matches email addresses, and checks that they are of the proper form. It checks to ensure the top level domain is between 2 and 4 characters long, but does not check the specific domain against a list (especially since there are so many ...

    Matches: [joe@aol.com], [joe@wrox.co.uk], [joe@domain.info] [ More Details]
    Non-Matches: [a@b], [notanemail], [joe@@.]
    "None of you [truly] believes until he wishes for his brother what he wishes for himself." By The one and Only Prophet Mohammed (Peace and blessings be upon him)

  8. #8
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx

  9. #9
    SitePoint Zealot devscripts's Avatar
    Join Date
    Sep 2004
    Location
    ur monitor
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    strlen($variable) to give you total number of characters. in your case the if

    if (strlen($_POST['email']) != "50" && ereg(pattern,blah..))
    "None of you [truly] believes until he wishes for his brother what he wishes for himself." By The one and Only Prophet Mohammed (Peace and blessings be upon him)

  10. #10
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed the MaxLength attribute of the textbox to 50,and now no one can type more than 50 chars.Its easier
    thx a lot for your help though

  11. #11
    SitePoint Zealot devscripts's Avatar
    Join Date
    Sep 2004
    Location
    ur monitor
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thats not the way. since i can create a form from my desktop and submit to you :s
    "None of you [truly] believes until he wishes for his brother what he wishes for himself." By The one and Only Prophet Mohammed (Peace and blessings be upon him)

  12. #12
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    never thought of that :O
    I've changed the filter now though.

  13. #13
    SitePoint Zealot devscripts's Avatar
    Join Date
    Sep 2004
    Location
    ur monitor
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "None of you [truly] believes until he wishes for his brother what he wishes for himself." By The one and Only Prophet Mohammed (Peace and blessings be upon him)


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
  •