i wish to restrict certain emails to my website.

a good example is i only want individuals with gmail accounts to join up to my website.



     if(!eregi($regex,$subemail))area, "* Email invalid")


     $subemail = stripslashes($subemail)


this is exactly what i've to date to see if its a legitimate email.

Avoid using just one regex for checking the whole address. Use strrpos() split the address to local part and domain title, check them individually. Domain is simple to check on, the neighborhood part is nearly impossible (and also you should not even worry about it).

It is best to keep a range of regex designs that you'd like the e-mail address to complement against. then write a loop to iterate within the array and appearance the address. each time a check unsuccessful, set some validation flag to false. following the loop, by checking the validation flag you are able to make certain the current email address is what you would like.

What about doing something similar to:

list(,$domain) = explode('@',$email)

if ($domain != 'gmail.com')

  echo 'not easy to register'


  echo 'Will register'

If you wish to validate the e-mail make use of the filter functions