OPINION : Check validity of email address

This is where you share YOUR scripts with others

Moderators: egami, macek, gesf

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

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,
Jon

User avatar
Strider64
php-forum Active User
php-forum Active User
Posts: 307
Joined: Sat Mar 23, 2013 8:24 am

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