[eluser]matches[/eluser]
Hello,
I am trying to get callback_ working but it doesn't seem to do anything. When I run this script it just goes straight to the insert statement. Currently I just want to echo my query when I call callback_ to make sure everything is working.
Thanks for any help.
Code:
function usernamecheck($str)
{
$this->db->select('userName');
$this->db->where('userName', $str);
$query = $this->db->get('users');
echo $query;
/*if ($str == $query)
{
$this->validation->set_message('username_check', 'The %s field can not be the word "test"');
return FALSE;
}
else
{
return TRUE;
}*/
}
function loadData()
{
$userName = $this->input->post('userName');
$email = $this->input->post('email');
$password = $this->input->post('password');
$passwordConfirm = $this->input->post('passwordConfirm');
$rules['userName'] = "trim|required|callback_usernamecheck";
$rules['password'] = "trim|required|matches[passconf]|md5";
$rules['passconf'] = "trim|required";
$rules['email'] = "trim|required|valid_email";
$this->validation->set_rules($rules);
$fields['username'] = 'Username';
$fields['password'] = 'Password';
$fields['passconf'] = 'Password Confirmation';
$fields['email'] = 'Email Address';
$this->validation->set_fields($fields);
if ($this->validation->run() == FALSE)
{
$this->load->view('register/index');
}
else
{
$data = array(
'userName' => $this->input->post('userName'),
'password' => $this->input->post('password'),
'firstname' => $this->input->post('firstName'),
'lastName' => $this->input->post('lastName'),
'address1' => $this->input->post('address1'),
'address2' => $this->input->post('address2'),
'city' => $this->input->post('city'),
'state' => $this->input->post('state'),
'zip' => $this->input->post('zip'),
'email' => $this->input->post('email'),
'signUpDate' => now()
);
$this->db->insert('users', $data);
redirect("register/registered");
}
}