Quick Fix for "Check Email Address" script

Discussion in 'Programming' started by BizMentor, Nov 24, 2008.

  1. #1
    Hi Folks,
    I have a site that has a form that checks for a valid email address.

    Right now everything is working fine for any emails that come in listed as

    People who have an email that reads are getting an "invalid email" error.

    The code presently reads as this:
    if(eregi("^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$",$emailAddr)){
    Code (markup):
    What can I add to this code to allow users with name.XX.XX.com emails to get through?

    $3 to the first to answer (other than NOT using the verify process ;) )

    Terry
     
    BizMentor, Nov 24, 2008 IP
  2. NetworkTown.Net

    NetworkTown.Net Well-Known Member

    Messages:
    2,022
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    165
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Try this dont know if it will work.

     
    if(eregi("^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$",$emailAddr)){ bla bla } 
    elseif(eregi("^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\+.[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$",$emailAddr)) { }
    
    Code (markup):
    Havent tested it out so could contain some errors but play around with that might just work.
     
    NetworkTown.Net, Nov 24, 2008 IP
  3. scrabblenerd

    scrabblenerd Member

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    try
    preg_match('/^[\w.-]+@([\w.-]+\.)+[a-z]{2,6}$/is', $email);
     
    scrabblenerd, Nov 24, 2008 IP
  4. BizMentor

    BizMentor Well-Known Member

    Messages:
    350
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    120
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    Thanks guys, no luck. I'm going to clarify and show a little more of the code. I know somebody is going to catch what to do as soon as they see it.
    
    $emailAddr = $_GET['email'];
    
    if(eregi("^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]+\.[a-zA-Z.]{2,5}$",$emailAddr)){
    	$ip = $_SERVER['REMOTE_ADDR'];
    	
    	$name = $_GET['name'];
    	
    	$country = $_REQUEST['country'];
    	
    	if(mysql_num_rows(mysql_query("SELECT * FROM contestant WHERE ip='$ip'"))!=NULL){
    	
    		echo "<div id=\"content-contest\"><div class=\"contest-txt-2\"><p>Someone has already registered for this contest from your IP address. We limit one entry per IP. This is to prevent duplicate entries.</p></div></div>";
    Code (markup):
     
    BizMentor, Nov 24, 2008 IP
  5. Bronto

    Bronto Peon

    Messages:
    308
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    
    if(eregi("^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]+\.[a-zA-Z.]{2,5}$",$emailAddr) || eregi("^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$",$emailAddr)){
    
    
    PHP:
    This should work.

    Regards,
    Bronto
     
    Bronto, Nov 24, 2008 IP
  6. BizMentor

    BizMentor Well-Known Member

    Messages:
    350
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    120
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    Thank you Bronto, that worked perfectly.

    Thank you scrabblenerd and networktown for your assistance.

    Terry
     
    BizMentor, Nov 24, 2008 IP