Guest User

Untitled

a guest
Jun 17th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. if ($input = $this->input->post()) {
  2.  
  3. $user = new User_Model(Session::get('user_id', FALSE));
  4. $profile = new Profile_Model(Session::get('user_id', FALSE));
  5.  
  6. $input_user = $this->input->post();
  7. $input_profile = $this->input->post();
  8.  
  9. if ( ! $user->validate($input_user)) {
  10. foreach ($input_user->errors('form_errors') as $error) {
  11. $errors[] = $error;
  12. }
  13. }
  14.  
  15. if ( ! $profile->validate($input_profile)) {
  16. foreach ($input_profile->errors('form_errors') as $error) {
  17. $errors[] = $error;
  18. }
  19. }
  20.  
  21. if (isset($errors)) {
  22. $json = array('success' => FALSE, 'errors' => $errors);
  23. $this->template->body = json_encode($json);
  24.  
  25. } else {
  26. if ( ! empty($input['password']))
  27. $user->hashed_password = Auth::hash_password($input['password']);
  28.  
  29. $user->save();
  30. $this->set_session_user();
  31.  
  32. $profile->save();
  33. $this->set_session_profile();
  34.  
  35. $json = array('success' => TRUE);
  36. $this->template->body = json_encode($json);
  37. }
  38. }
Add Comment
Please, Sign In to add comment