Jump to content


Photo

email validation


  • Please log in to reply
1 reply to this topic

#1 Woodburn2006

Woodburn2006
  • Members
  • PipPipPip
  • Advanced Member
  • 214 posts

Posted 15 September 2006 - 03:15 PM

im trying to use this code to validate an e-mail address but everything i try comes out as valid, even if it is blatently not valid:

<?php
function checkEmail($email) 
{
   if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) 
   {
      return FALSE;
   }else{
   	return TRUE;
	}
}
if (isset($_POST['submit'])) {
    $email = trim(strip_tags($_POST['email_address']));
    if(checkEmail($email) == FALSE) {
       echo "E-mail entered is not valid.";
    } else {
       echo "E-mail entered is valid.";
    }
} else {
?>

<form method="post" action="<? $_SERVER['PHP_SELF']; ?>">
Email<input type="text" name="email_address" size="30"/>
<input type="submit" name="submit" value="Register">
</form>
<?php
}
?>

any ideas why it is doing this?

#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 15 September 2006 - 03:49 PM

here's the code from andy b's captcha script... works for me:

if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))...





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users