OPINION : Check validity of email address

This is where you share YOUR scripts with others

Moderators: egami, macek, gesf

Post Reply
php-forum Fan User
php-forum Fan User
Posts: 628
Joined: Sat Jun 06, 2015 11:46 am

Thu Oct 22, 2015 2:38 am

In HTML5 you can use

Code: Select all

<input type="email" required name="email_address">
which saves lots of validation requirements.

Hope that helps,

User avatar
php-forum Active User
php-forum Active User
Posts: 315
Joined: Sat Mar 23, 2013 8:24 am
Location: Livonia, MI

Thu Oct 22, 2015 9:56 am

I like K.I.S.S. (Keep It Simple Stupid) ->

Code: Select all

$email = "john.doe@example.com";

if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
  echo("$email is a valid email address");
} else {
  echo("$email is not a valid email address");

Post Reply