Welcome Guest, Not a member yet? Register   Sign In
Twitter-like Registration with DX Auth
#2

[eluser]xzela[/eluser]
Actually, I've done something very similar to what you've described. I didn't use the Auth library you supplied but my method should work nearly the same way.

I created a Callback using the form validation library. however, i didn't call it via a typical post request. I called it with a jQuery ajax.post request. If the call back found a match for that username, it would respond with a message.

See jQuery post documentation here:
http://docs.jquery.com/Post

Registration controller:
Code:
$this->load->library('form_validation');
$this->form_validation->set_rules('user_name', 'User Name', 'trim|required|callback_CB_testUserName);
$this->form_validation->set_message('test_username', 'That username is already taken. Please choose another one');
// more code here ...
// ...
$json = array();
$json['validation'] = validation_errors();
echo json_enchode($json);


callback function
Code:
function CB_testUserName($str) {
  $this->load->model('register_model');
   return $this->register_model->testUsername($str);
}

registration model
Code:
function testUsername($name) {
  $b = true;
  $this->db->from('user_table');
  $this->db->where('user_name', $name);
  $query = $this->db->get();
  if($query->num_rows > 0) {
    $b = false;
  }
  return $b;
}

that should do it.


Messages In This Thread
Twitter-like Registration with DX Auth - by El Forum - 07-26-2009, 07:49 PM
Twitter-like Registration with DX Auth - by El Forum - 07-27-2009, 05:04 PM
Twitter-like Registration with DX Auth - by El Forum - 07-27-2009, 06:36 PM
Twitter-like Registration with DX Auth - by El Forum - 08-10-2009, 02:35 PM
Twitter-like Registration with DX Auth - by El Forum - 08-10-2009, 07:22 PM
Twitter-like Registration with DX Auth - by El Forum - 08-12-2009, 05:15 AM
Twitter-like Registration with DX Auth - by El Forum - 08-12-2009, 06:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB