Posted By

phpdev on 09/14/13


Tagged

regex email mail check security college school university edu


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Priestd09


Check University Email (.edu)


 / Published in: PHP
 

Example of use:

if (!isUniversityEmail('[email protected]'))
     exit('You must have a valid and .edu email address to register for an account.');
  1. /**
  2.  * @title Check if it is a valid and university email address.
  3.  *
  4.  * @author Pierre-Henry Soria <[email protected]>
  5.  * @copyright (c) 2013, Pierre-Henry Soria. All Rights Reserved.
  6.  * @param string $sEmail
  7.  * @return boolean
  8.  */
  9. function isUniversityEmail($sEmail)
  10. {
  11. return preg_match('/^[a-z0-9_\-]+(\.[_a-z0-9\-]+)*@([_a-z0-9\-]+\.)+edu$/i', $sEmail);
  12. }

Report this snippet  

You need to login to post a comment.