0

Possible Duplicates:
PHP email validation function
Is there a php library for email address validation?

I have a contact form on my site but I need a e-mail validation and I don't know how to do it.

Community
  • 1
  • 1
stijn
  • 31
  • 2
  • 6

2 Answers2

2
$email = "someone@example.com";

if(!filter_var($email, FILTER_VALIDATE_EMAIL))
  {
  echo "E-mail is not valid";
  }
else
  {
  echo "E-mail is valid";
  }

This is probably the simplest method. The example I pasted above is from http://www.w3schools.com/php/filter_validate_email.asp and complete documentation on using filter_var is available at http://us2.php.net/manual/en/function.filter-var.php

Erik
  • 20,526
  • 8
  • 45
  • 76