public function register() { $data['message'] = ""; $this->form_validation->set_rules('username', 'Username', 'trim|required|valid_email|max_length[60]|xxs_clean'); $this->form_validation->set_rules('password', 'Password', 'trim|required|matches[password_c]|max_length[16]|min_length[8]|md5'); $this->form_validation->set_rules('password_c', 'Confirm password', 'trim|required||md5'); $this->form_validation->set_rules('nickname', 'nickname', 'trim|required|max_length[30]|min_length[2]'); $this->form_validation->set_rules('name', 'name', 'trim|required|max_length[30]|min_length[2]'); $this->form_validation->set_rules('surname', 'last name', 'trim|required|max_length[30]|min_length[2]'); $this->form_validation->set_rules('mb_no', 'mobile number', 'trim|max_length[10]|min_length[10]'); if ($this->form_validation->run() == TRUE) { if (ctype_alpha($this->input->post('name')) && ctype_alpha($this->input->post('surname'))) { $rm = new Register_model(); $rm->username = $this->input->post('username'); $rm->password = $this->input->post('password'); $rm->nickname = $this->input->post('nickname'); $rm->name = $this->input->post('name'); $rm->surname = $this->input->post('surname'); if ($rm->mb_no = $this->input->post('mb_no')) { } else { $rm->mb_no = "00"; } $lm = new Login_model(); $lm->username = $this->input->post('username'); $lm->password = $this->input->post('password'); if ($rm->save()) { $data['message'] = 'Registration successful'; if ($lm->authenticate()) { redirect('user', 'Location'); } else { $data['message'] = 'Some Error Occured'; } } else { $data['message'] = 'Some Error Occured'; } } else { $data['message'] = 'Name or Surname is incorrect'; } } $this->load->helper('url', $data); $this->load->helper('form', $data); $this->load->view('header/header_without', $data); $this->load->view('register', $data); $this->load->view('sidebar/right_sidebar', $data); $this->load->view('footer/footer', $data); }
public function save() { $this->db->trans_start(); $this->db->query('insert into auth values("' . $this->username . '","' . $this->password . '",default)'); $obj = Register_model::get_uid($this->username); $this->db->query('update userinfo set nickname="' . $this->nickname . '" ,name="' . $this->name . '" ,surname="' . $this->surname . '", mb_no=' . $this->mb_no . "\r\n\t\t\twhere uid=" . $obj->uid); $this->db->trans_complete(); if ($this->db->trans_status() === FALSE) { return FALSE; } else { return TRUE; } }