erinther wrote:Thank you for the reply. the only thing left is that I am making a froum for a university staff and their email addresses are like this:
@hf.uio.com, @ili.uio.com, @mat.uio.com and so on... Your reply solves my first questions. but regarding this type of emails, how should I change the code? Thanks again.
Either you define all the allowed subdomains:
return preg_match('/^(([^<>()[\]\\.,;:\s@"\']+(\.[^<>()[\]\\.,;:\s@"\']+)*)|("[^"\']+"))@(hf|ili|mat)\.uio\.com$/', $email);
Or you just allow everyone from uio.com to register:
return preg_match('/^(([^<>()[\]\\.,;:\s@"\']+(\.[^<>()[\]\\.,;:\s@"\']+)*)|("[^"\']+"))@(.+\.|)uio\.com$/', $email);
(You should test that code before you use it, I just copied Nibbler's example and changed the domain.)