Second Sighting Logo

Simple Email Validation

Posted in PHP by Tom on the July 3rd, 2007

Starting with PHP 5.2.0 there is a really easy way to validate email addresses – namely the filter_input function. The example below takes a submitted POST variable called ‘email’, validates it against the email format, and returns FALSE if the filter fails or the value of the variable on success.

  1. $email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);

Thats all there is to it.

0 Comments

Leave a Reply