public function showRegister()
{
$this->template->set('title', 'test register');
$this->template->load('template', 'index/register', $data);
}
public function doRegister()
{
$this->form_validation->set_rules('email', 'Email', 'required|trim|max_length[30]|xss_clean|valid_email|is_unique[users.email]|');
$this->form_validation->set_rules('password', 'Password', 'required|trim|min_length[6]|max_length[20]|xss_clean|alpha_dash');
$this->form_validation->set_rules('rrpassword', 'Re Password', 'required|trim|min_length[6]|max_length[20]|xss_clean|matches[password]|alpha_dash');
if($this->form_validation->run() == FALSE)
{
$this->showRegister();
}
else
{
$email = $this->input->post('email');
$pass = $this->input->post('password');
$password = $this->bcrypt->hash_password($pass);
// check if the password was encrypted
if ($this->bcrypt->check_password($pass, $password))
{
$data =array(
'email' => $email,
'password' => $password,
);
$insert = $this->user_model->register($data);
if(!$insert)
{
echo 'error';
}
$this->session->set_flashdata('info', 'registered');
redirect('login', 'refresh');
}
else
{
$this->session->set_flashdata('info', 'Oops.. error...');
redirect(base_url('login'), 'refresh');
}
}
}