...

View Full Version : Help validating email address inputs



Cjc1706
03-01-2012, 04:11 PM
Hi,

I currently have a website that is specific to the academic / university area, and as such, I only want people with a .ac.uk email address to be able to register.

I currently have a script in place to check that a valid email address is submitted in the correct format ie email@address.co.uk or .com etc etc.

I am having trouble trying to create a validation check to make sure that ONLY email addresses ending in .ac.uk (email@address.ac.uk) are accepted ... everything else such as .co.uk .com etc would get declined.

Any help would be greatly appreciated!

Thanks

Keleth
03-01-2012, 04:21 PM
if (substr($email, -6) == '.ac.uk') // valid

Of course, you'll still want to validate the email as a whole, but that'll confirm the last 6 characters are '.ac.uk'.

Cjc1706
03-01-2012, 04:28 PM
if (substr($email, -6) == '.ac.uk') // valid

Of course, you'll still want to validate the email as a whole, but that'll confirm the last 6 characters are '.ac.uk'.

Perfect! That works a treat! Thank you very much!! :thumbsup: :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum