public function addUserPro() { $this->load->model("dao/DaoUser"); $this->load->model("dto/DtoUser"); $user = new DtoUser(); $userDao = new DaoUser(); $this->load->library('form_validation'); $this->load->helper('form'); $this->form_validation->set_rules('username', 'Username', 'required|trim'); $this->form_validation->set_rules('password', 'Password', 'required|trim'); $this->form_validation->set_rules('confirm_password', 'Confirm Password', 'required|trim'); $this->form_validation->set_rules('usertype', 'User Type', 'required|trim'); $this->form_validation->set_rules('status', 'Status', 'required|trim'); if ($this->form_validation->run() == FALSE) { echo json_encode(array("ERROR" => true, "ERR_MSG" => validation_errors())); } else { if ($this->input->post('password') != $this->input->post('confirm_password')) { echo json_encode(array("ERROR" => true, "ERR_MSG" => "Your password are mismatch. Please enter again.")); } else { $user->setUsername($this->input->post('username')); $user->setPassword($this->input->post('password')); $user->setUsertype($this->input->post('usertype')); $user->setActive($this->input->post("status")); if ($userDao->check_duplicate_user_by_username($user->getUsername()) > 0) { $data["ERROR"] = true; $data["ERR_MSG"] = "User already exist."; } else { $userDao->create_new_user($user); $data["ERROR"] = false; $data["ERR_MSG"] = "User has been inserted sucessfully."; } echo json_encode($data); } } }
function login(DtoUser $user) { $this->db->select('userid, username, usertype'); $this->db->from('USERS'); $this->db->where('username', $user->getUsername()); $this->db->where('password', $user->getPassword()); $this->db->where('active', 1); $this->db->limit(1); $query = $this->db->get(); if ($query->num_rows() == 1) { return $query->result(); } else { return false; } }
function login(DtoUser $user) { $this->db->select('id, name, usertype'); $this->db->from('dbsc_users_ci'); $this->db->where('username', $user->getUsername()); $this->db->where('password', $this->securityapi->encrypt($user->getPassword())); $this->db->where('block', 0); $this->db->limit(1); $query = $this->db->get(); if ($query->num_rows() == 1) { return $query->result(); } else { return false; } }