public function create_member() { $new_member_insert = array('email' => $this->input->post('email'), 'hash' => md5(rand(0, 1000))); send_verification_mail($new_member_insert['email'], $new_member_insert['hash']); $insert = $this->db->insert('user_activations', $new_member_insert); return $insert; }
public function register() { // if($this->session->userdata('logged_in')){ // redirect('home/index'); //} $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|xss_clean'); $passedCases = true; if ($this->form_validation->run() == FALSE) { //Load view and layout $data['main_content'] = 'users/register'; $this->load->view('layouts/main', $data); //Validation has ran and passed } else { $passedCases = false; $email = $this->input->post('email'); if (!$this->User_model->validate_user_exists($email)) { if (!$this->User_activation_model->validate_user_exists($email)) { if ($this->User_activation_model->create_member()) { $this->session->set_flashdata('registered', 'verificaion email have been sent, please verify the account'); //Redirect to index page with error above redirect('home/index'); } } else { $objUserActivation = $this->User_activation_model->get_user_activation_by_email($email); send_verification_mail($objUserActivation->email, $objUserActivation->hash); $this->session->set_flashdata('registered', 'verificaion email have been resent, please verify the account'); redirect('home/index'); } } else { $this->session->set_flashdata('already_member', 'You are already registered.Please login'); redirect('home/index'); } } }