Jump to content

Archived

This topic is now archived and is closed to further replies.

Woodburn2006

email validation

Recommended Posts

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:

[code]<?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
}
?>[/code]

any ideas why it is doing this?

Share this post


Link to post
Share on other sites
here's the code from andy b's captcha script... works for me:

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.