Jump to content

Archived

This topic is now archived and is closed to further replies.

white_rajah

Question about syntax in e-mail domain screening function

Recommended Posts

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 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)[/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

Share this post


Link to post
Share on other sites
Somone on another forum cracked it for me:

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

Thanks anyway!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.