Online: 103   Members: 4,232

Validating Email Addresses

Creating an email validation script is a very useful tool for insuring quality of your stored information. Also, the script is very easy.

<?php
$email = "something@website.com";
if(ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$]", $email))
{
  echo "Valid Email";
} else {
  echo "Invalid Email!";
  exit();
}
?>

By setting $email to whatever you want, the script essentially checks that the email is some string followed by "@" followed by a string followed by "." followed by a string.

Related Tutorials

Useful Resources