Help - Search - Members - Calendar
Full Version: Only Allow Certain Emails To Register
BleepingComputer.com > Internet & Networking > Web Site Development
   
xx66stangxx
Ok so I have a project in mind which is create a social network for my college. but when the user registers I want to make sure they are an actual student of the college so they would have to sign up with the college email they use i.e. student@csu.fullerton.edu now is that possible? I realize that each student has a dif. prefix in the email but all the current student emails are @csu.fullerton.edu now how would I do that for the registration page?
groovicus
You would use some form of regular expression matching. But that still doesn't guarantee that they will give you a valid email address because "bozosrus@csu.fullerton.edu" would pass the same test that a valid address would. So the other option is that once they sign up, you send them a validation e-mail to which they have to respond before they can actually use the account.
xx66stangxx
ok I will look that up, yeah I planned on doing the validation email :-)
groovicus
If you are doing a validation email, then there is no need to check anything. Either they give a proper email address and get the validation link, or they do not give a proper address and do not get a validation link.

EDIT: Of course, that doesn't answer your original question. You can use javascript to initially check that the the address contains the required @csu.fullerton.edu, but all it will be checking isthat the address contains the proper domain. The regular expression used to match it is pretty simple. I nabbed this code from some random page and modified it. I did not test it, but it should be close:
CODE
function checkMail()
{
    var x = document.forms[0].email.value;
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(csu.fullerton.edu)$/;
    if (filter.test(x)) alert('YES! Correct email address');
    else alert('NO! Incorrect email address');
}


This code only checks the address. It does not pass on the string if it is valid. There are tons of code samples for form validation, so you should have no problem finding something that works. On the server side, you will just need something to generate the validation email, and then a form that recognizes when a validation link has been clicked. Is it the back-end mechanism that you are asking about?
ussr1943
You could also use php to validate any inputs(requires host that supports php, and possibly database), then store all your info in a database for later retrieval(sending emails out). However if you do plan on saving user information please remember
1.) protect against database injections, xss, csrf ect.
2.) always encrpyt user information(if being stored), hashes and salts to prevent anyone outside from atleast understanding your stored info

There are many means to the end, you might just want to do a little online research first.

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.