Esempio n. 1
0
 public function post_register()
 {
     $this->load->library('form_validation');
     $this->form_validation->set_rules('cl_type', 'User Type', 'trim|is_natural_no_zero|required|max_length[1]|callback_isCheckUserType');
     $this->form_validation->set_rules('fname', 'First Name', 'trim|required|xss_clean');
     $this->form_validation->set_rules('lname', 'Last Name', 'trim|required|xss_clean');
     $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|is_unique[pl_user.email]');
     $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
     $fname = $this->input->post('fname');
     $lname = $this->input->post('lname');
     $email = $this->input->post('email');
     $pass = MD5($this->input->post('password'));
     $role_id = $this->input->post('cl_type');
     $user_id = $this->input->post('user_id');
     if ($this->form_validation->run() == FALSE) {
         $data['title'] = 'Create Users';
         $data['content'] = 'client/create_users';
         $this->load->view($this->layout_client, $data);
     } else {
         $user_data = array('email' => $email, 'password' => $pass, 'role_id' => $role_id, 'acc_id' => 0, 'ref_id' => $user_id, 'acc_active' => 1, 'is_active' => 1);
         $meta_user_id = registerUserData($user_data);
         $meta_fname = array('user_id' => $meta_user_id, 'meta_key' => 'first_name', 'meta_value' => $fname);
         $meta_lname = array('user_id' => $meta_user_id, 'meta_key' => 'last_name', 'meta_value' => $lname);
         setUserMeta($meta_fname);
         setUserMeta($meta_lname);
         redirect('client/createusers');
     }
 }
Esempio n. 2
0
 public function post_register()
 {
     $acc_type = $this->input->post('ClientType');
     if ($acc_type == 0) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('c_name', 'Company Name', 'trim|required|xss_clean');
         $this->form_validation->set_rules('c_regnum', 'Company Register Number', 'trim|required|xss_clean');
         $this->form_validation->set_rules('c_email', 'Email', 'trim|required|valid_email|callback_isCompanyEmailExist');
         $this->form_validation->set_rules('c_pass', 'Password', 'trim|required|matches[c_cpass]|md5');
         $this->form_validation->set_rules('c_cpass', 'Password Confirmation', 'trim|required');
         $c_name = $this->input->post('c_name');
         $c_regnum = $this->input->post('c_regnum');
         $c_email = $this->input->post('c_email');
         $c_pass = MD5($this->input->post('c_pass'));
         if ($this->form_validation->run() == FALSE) {
             $data['title'] = 'Admin Register';
             $data['content'] = 'client/user_register';
             $this->load->view($this->layout, $data);
         } else {
             $company_data = array('email' => $c_email, 'password' => $c_pass, 'role_id' => 2, 'acc_id' => $acc_type, 'acc_active' => 0, 'is_active' => 1);
             $user_id = registerUserData($company_data);
             $meta_cname = array('user_id' => $user_id, 'meta_key' => 'company_name', 'meta_value' => $c_name);
             $meta_cregnum = array('user_id' => $user_id, 'meta_key' => 'company_reg_num', 'meta_value' => $c_regnum);
             setUserMeta($meta_cname);
             setUserMeta($meta_cregnum);
             redirect('client/user/login');
         }
     } else {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('u_fname', 'First Name', 'trim|required|xss_clean');
         $this->form_validation->set_rules('u_lname', 'Last Name', 'trim|required|xss_clean');
         $this->form_validation->set_rules('u_email', 'Email', 'trim|required|valid_email|callback_isUserEmailExist');
         $this->form_validation->set_rules('u_pass', 'Password', 'trim|required|matches[u_cpass]|md5');
         $this->form_validation->set_rules('u_cpass', 'Password Confirmation', 'trim|required');
         $u_fname = $this->input->post('c_fname');
         $u_lname = $this->input->post('u_lname');
         $u_email = $this->input->post('u_email');
         $u_pass = MD5($this->input->post('u_pass'));
         if ($this->form_validation->run() == FALSE) {
             $data['title'] = 'Admin Register';
             $data['content'] = 'client/user_register';
             $this->load->view($this->layout, $data);
         } else {
             $user_data = array('email' => $u_email, 'password' => $u_pass, 'role_id' => 2, 'acc_id' => $acc_type, 'acc_active' => 0, 'is_active' => 1);
             $user_id = registerUserData($user_data);
             $meta_fname = array('user_id' => $user_id, 'meta_key' => 'first_name', 'meta_value' => $u_fname);
             $meta_lname = array('user_id' => $user_id, 'meta_key' => 'last_name', 'meta_value' => $u_lname);
             setUserMeta($meta_fname);
             setUserMeta($meta_lname);
             redirect('client/user/login');
         }
     }
 }