validation - PHP: How to add more parameters to filter_var() to match also specific domains? -


i have html form email field want validate. i'm processing form php, used filter_var() function.

the thing also want filter emails not contain 3 specific domains after @ sign (like email inserted should filtered if not legal, , if not @example.com, @example2.com or @example3.com).

how may that?:

<?php if (!filter_var($_post['emailremitente'], filter_validate_email)) {         echo "<br>oops! not valid email";     } else { ... 

// array of domains rejected - domains must lower case $rejecteddomains = array('yahoo.com', 'hotmail.com', 'gmail.com'); // break email address (assuming have validated email already) $emailparts = explode('@',$_post['emailremitente']); // check if second element (the domain) in $rejecteddomains if (in_array(strtolower($emailparts[1]), $rejecteddomains)) {     // rejected domain } else{     // accepted domain } 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -