Welcome Guest, Not a member yet? Register   Sign In
Testing an Email form for a specific domain?
#1

[eluser]SSgt Dodger USMC[/eluser]
I have an email form that I am validating, and I need to be able to check and see what domain users are typing in. for example, I want users to only be able to unter emails that end in server.example.com. This means that people from my.server.example.com and your.server.example.com would be valid, but other.server.com (or anything else) would not.

I currently have:
Code:
$this->form_validator->set_rules('email1', 'Email Address','required|valid_email');
and that works for the email, but I need to allow select domains only.

Can anyone help me out, as I am not the greatest programmer...

Any help is greatly appreciated!
#2

[eluser]Thorpe Obazee[/eluser]
You could use a callback to check.
#3

[eluser]Fatih[/eluser]
You should check this sentence for form validate:

Code:
$this->form_validator->set_rules('email1', 'Email Address','required|valid_email|callback__checkdomain');

And here is the callback function:

Code:
function _checkdomain{$data}
{
   $email1= $this->input->post("email1");
   if (strpos($email1,"other.server.com"))
   {
     return FALSE;
   } else return TRUE;

}

Hope you like it.
#4

[eluser]SSgt Dodger USMC[/eluser]
Ah! Thanks fatigue! That's what I was looking for. You've helped me out a ton!




Theme © iAndrew 2016 - Forum software by © MyBB