white_rajah Posted July 1, 2006 Share Posted July 1, 2006 Hi everyone - I'm a PHP-newbie, and my skills at this point are pretty limited. I got some wonderful help from the folks at Joomla forums in putting together a function to restrict attempts to register at a site to a certain e-mail domain:[quote]// hack by Kenneth Crowder (ChiefGoFor) to allow registration to be restricted by domain. (6-30-2006)if ($_REQUEST[option]=="com_registration" && ((trim($this->email == "")) || (preg_match("/[\w\.\-]+@university.edu/", $this->email )==false))) { $this->_error = 'Sorry, but only users with email addresses ending in "university.edu" may register.'; return false;}else if ((trim($this->email == "")) || (preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $this->email )==false)) { $this->_error = _REGWARN_MAIL; return false;}[/quote]The code works beautifully, but my needs are a little more complex than this. I'm dealing with registration for a university society, at a school where e-mail addresses can have multiple subdomains, and which has more than one domain name. To state what I'm trying to do in natural language, in the hope that someone can help me translate it into PHP, here's what I would like this function to do:[quote]if address = [*member*]@[*subdomain*].[university].edu, register this person, otherwise return error messageor if address = [*member*]@[*subdomain*].[university-other-domain].edu, register this person, otherwise return error message(where *member* and *subdomain* are both wildcards, but university and university-other-domain represent fixed strings)[/quote]Thanks in advance to anyone who can point me in the right direction!Original post on Joomla forums: http://forum.joomla.org/index.php/topic,73427.msg379972.html Quote Link to comment https://forums.phpfreaks.com/topic/13414-question-about-syntax-in-e-mail-domain-screening-function/ Share on other sites More sharing options...
white_rajah Posted July 1, 2006 Author Share Posted July 1, 2006 Somone on another forum cracked it for me:/.+@(.+\.)?(university|university-other-domain)\.edu/Thanks anyway! Quote Link to comment https://forums.phpfreaks.com/topic/13414-question-about-syntax-in-e-mail-domain-screening-function/#findComment-51787 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.