Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-01-2012, 03:11 PM   PM User | #1
Cjc1706
New to the CF scene

 
Join Date: Mar 2011
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Cjc1706 is an unknown quantity at this point
Exclamation Help validating email address inputs

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
Cjc1706 is offline   Reply With Quote
Old 03-01-2012, 03:21 PM   PM User | #2
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
PHP Code:
 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'.
Keleth is offline   Reply With Quote
Users who have thanked Keleth for this post:
Cjc1706 (03-01-2012)
Old 03-01-2012, 03:28 PM   PM User | #3
Cjc1706
New to the CF scene

 
Join Date: Mar 2011
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Cjc1706 is an unknown quantity at this point
Quote:
Originally Posted by Keleth View Post
PHP Code:
 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!!
Cjc1706 is offline   Reply With Quote
Reply

Bookmarks

Tags
email validation

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:43 PM.


Advertisement
Log in to turn off these ads.