Welcome Guest, Not a member yet? Register   Sign In
Validate Email within Custom Callback?
#1

[eluser]Corey Freeman[/eluser]
Another registration problem...how do I check if an email is valid or not? I'm using the email helper but I can't seem to integrate it into the function properly...

Code:
function email_check($str) {
        //This field is required and cannot be blank.
        if ($str == '') {
            $this->form_validation->set_message('email_check', 'The Email Field is Required');
            return FALSE;
        }
        //Is the email valid?
        $this->load->helper('email');
        elseif (!valid_email($str)) {
            $this->form_validation->set_message('email_check', 'Please Enter a Valid Email Address');
            return FALSE;
        }
        //Does the email already exist in the database? That's a no no.
        $query = $this->db->get('players');
        foreach ($query->result() as $row):
        $email_exist = $row->email_address;
        endforeach;
        elseif ($str == $email_exist)
        {
            $this->form_validation->set_message('email_check', 'That Email Already Exists');
            return FALSE;
        }
        else
        {
            return TRUE;
        }
    }

Instead of checking to see if it's valid, I want to check and see if it's invalid. Is there a way to do that?


Messages In This Thread
Validate Email within Custom Callback? - by El Forum - 07-05-2010, 04:31 AM
Validate Email within Custom Callback? - by El Forum - 07-05-2010, 04:44 AM
Validate Email within Custom Callback? - by El Forum - 07-05-2010, 05:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB