Welcome Guest, Not a member yet? Register   Sign In
ajax jquery duplicate checker error
#1

[eluser]Corbee[/eluser]
Hi,

I tried to use validate plugin's remote parameter to check for email duplicate, but it appears that I'm not returning the correct value jquery understands

This is my html code

Code:
<input class="required email" name="email" id="email"><br/>

and here is my php code

Code:
function getemail()
    {
        $this->db->select('Email');
        $q = $this->db->post('client');
        
        if ($q->num_rows() > 0)
        {
            foreach ($q->result_array() as $row)
            {
                $data[] = $row;
            }
            $q->free_result();    
            return $data;
        }
    }

here is my ajax
Code:
$("#signupForm").validate
({
   rules:
   {
        email:
        {
             remote:
             {
                 url: "<?php echo base_url();?>index.php/register/emailchecker",    
                 type: "post"
             }
         },
    message:
    {
         email:
         {
             message:
             {
                remote: "Email already exists"
             }
         }



Where did I do wrong?

Thanks
#2

[eluser]Nick_MyShuitings[/eluser]
Quote:function getemail()
{
$this->db->select('Email');
$q = $this->db->post('client');

if ($q->num_rows() > 0)
{
foreach ($q->result_array() as $row)
{
$data[] = $row;
}
$q->free_result();
return $data;
}
}

first off I think your error is $this->db->post which is not a function of active record unless you've extended. Which would mean that $q prolly isn't getting any information and you're prolly not even hitting the return.

It looks like you are wanting to do the following:
Code:
$this->db->select('Email');
$this->db->get_where('client', array('Email' => $email));

That is if I understand that the purpose of this callback is to see if the email already exists in the database?




Theme © iAndrew 2016 - Forum software by © MyBB