Welcome Guest, Not a member yet? Register   Sign In
Checking for specific domain in email address?
#1

[eluser]Wonder Woman[/eluser]
Hi,

I'm trying to check if a user is registering with the correct email address, it must be of a specific domain... for example [email protected]

I found a script on the web and tried changing it with no luck, can you help me please?

Code:
function _valid_domain($str)
{
list($mailbox, $domain) = split('@', $str);
if (!(checkdnsrr($domain, 'MX') || checkdnsrr($domain, 'A'))) {
  $this->form_validation->set_message(__FUNCTION__, "Domain "{$domain}" not found.");
  echo $domain;
  return FALSE;
} else {
  if($domain == "mywebsite.com"){
   return TRUE;
  } else {
   return FALSE;
  }
}
}

Code:
$this->form_validation->set_rules('email', 'Email address', 'trim|required|xss_clean|valid_email|callback__valid_domain');


Messages In This Thread
Checking for specific domain in email address? - by El Forum - 03-26-2012, 07:56 AM
Checking for specific domain in email address? - by El Forum - 03-26-2012, 08:05 AM
Checking for specific domain in email address? - by El Forum - 03-26-2012, 08:13 AM
Checking for specific domain in email address? - by El Forum - 03-26-2012, 08:16 AM
Checking for specific domain in email address? - by El Forum - 03-26-2012, 08:26 AM
Checking for specific domain in email address? - by El Forum - 03-26-2012, 08:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB