Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. public function edit($id)
  2. {
  3. $this->load->library('form_validation');
  4.  
  5. $this->form_validation->set_rules('fullname', 'Name', 'required');
  6. $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|is_unique[user.username]');
  7. $this->form_validation->set_rules('password', 'Password', 'required|min_length[5]');
  8. $this->form_validation->set_rules(
  9. 'passconf',
  10. 'Konfirmasi Password',
  11. 'required|matches[password]',
  12. array('matches' => '%s tidak sesuai dengan password')
  13. );
  14. $this->form_validation->set_rules('level', 'Level', 'required');
  15.  
  16. $this->form_validation->set_message('required', '%s masih kosong, silahkan isi');
  17. $this->form_validation->set_message('min_length', '{field} minimal 5 karakter');
  18. $this->form_validation->set_message('is_unique', '{field} ini sudah dipakai, silahkan ganti');
  19.  
  20. $this->form_validation->set_error_delimiters('<span class="help-block">', '</span>');
  21.  
  22. if ($this->form_validation->run() == FALSE) {
  23. $this->template->load('template', 'user/user_form_edit');
  24. } else {
  25. $post = $this->input->post(null, TRUE);
  26. $this->user_m->edit($post);
  27. if ($this->db->affected_rows() > 0) {
  28. echo "<scirpt>alert('Data berhasil disimpan');</script>";
  29. }
  30. echo "<script>window.location='" . site_url('user') . "';</script>";
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement