public function verify_regis() { $this->form_validation->set_rules('username', 'ชื่อผู้ใช้', 'trim|required'); $this->form_validation->set_rules('password', 'รหัสผ่าน', 'trim|required'); $this->form_validation->set_rules('name', 'ชื่อ', 'trim|required'); $this->form_validation->set_rules('lname', 'นามสกุล', 'trim|required'); $this->form_validation->set_rules('usertype', 'ตำแหน่ง', 'trim|required'); $this->form_validation->set_message('required', 'คุณยังไม่ได้กรอก %s !!'); if ($this->form_validation->run() == FALSE) { parent::core_admin_view('admin/add_user'); } else { if ($this->input->post('usertype') == '2') { $table = "doctors"; $pre = "doc_"; $funciton = "list_doctors"; } elseif ($this->input->post('usertype') == '3') { $table = "staffs"; $pre = "sf_"; $funciton = "list_staff"; } elseif ($this->input->post('usertype') == '4') { $table = "techs"; $pre = "tech_"; $funciton = "list_tech"; } $data_user = array('username' => $this->input->post('username'), 'password' => $this->input->post('password'), 'usertype' => $this->input->post('usertype'), 'cr_date' => date('Y-m-d'), 'user_status' => 1); $this->general_model->insert('users', $data_user); $user_id = $this->db->insert_id(); $data_regis = array($pre . 'name' => $this->input->post('name'), $pre . 'lname' => $this->input->post('lname'), 'usertype' => $this->input->post('usertype'), 'user_id' => $user_id); $this->general_model->insert($table, $data_regis); redirect(base_url() . 'admin/' . $funciton); die; } // parent::core_view('regis'); }