Jump to content


Photo

Question about syntax in e-mail domain screening function


  • Please log in to reply
1 reply to this topic

#1 white_rajah

white_rajah
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 01 July 2006 - 09:37 PM

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:

// 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;
}


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:

if address = [*member*]@[*subdomain*].[university].edu, register this person, otherwise return error message
or 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)


Thanks in advance to anyone who can point me in the right direction!

Original post on Joomla forums: http://forum.joomla.....msg379972.html

#2 white_rajah

white_rajah
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 01 July 2006 - 10:47 PM

Somone on another forum cracked it for me:

/.+@(.+\.)?(university|university-other-domain)\.edu/

Thanks anyway!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users