Guest User

Untitled

a guest
Jan 13th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. function signup()
  2. {
  3. $this->load->helper('ionauth');
  4.  
  5.  
  6. if($this->ion_auth->logged_in() == true)
  7. {
  8. redirect('auth', 'refresh');
  9. }
  10.  
  11. //validate form input
  12. $this->form_validation->set_rules('username', 'Username', 'username_check|required|xss_clean');
  13. $this->form_validation->set_rules('email', 'Email Address', 'email_check|required|valid_email');
  14. $this->form_validation->set_rules('password', 'Password', 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]');
  15. $this->form_validation->set_rules('password_confirm', 'Password Confirmation', 'required');
  16.  
  17. if ($this->form_validation->run() == true)
  18. {
  19. $username = $this->input->post('username');
  20. $email = $this->input->post('email');
  21. $password = $this->input->post('password');
  22.  
  23. $additional_data = array();
  24. }
  25. if ($this->form_validation->run() == true && $this->ion_auth->register($username, $password, $email, $additional_data))
  26. { //check to see if we are creating the user
  27. //redirect them back to the admin page
  28. $this->session->set_flashdata('message', "User Created");
  29. redirect("users", 'refresh');
  30. }
  31. else
  32. { //display the create user form
  33. //set the flash data error message if there is one
  34. $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
  35.  
  36.  
  37. $this->data['username'] = array(
  38. 'name' => 'username',
  39. 'id' => 'username',
  40. 'type' => 'text',
  41. 'value' => $this->form_validation->set_value('username'),
  42. );
  43. $this->data['email'] = array(
  44. 'name' => 'email',
  45. 'id' => 'email',
  46. 'type' => 'text',
  47. 'value' => $this->form_validation->set_value('email'),
  48. );
  49.  
  50. $this->data['password'] = array('name' => 'password',
  51. 'id' => 'password',
  52. 'type' => 'password',
  53. 'value' => $this->form_validation->set_value('password'),
  54. );
  55. $this->data['password_confirm'] = array('name' => 'password_confirm',
  56. 'id' => 'password_confirm',
  57. 'type' => 'password',
  58. 'value' => $this->form_validation->set_value('password_confirm'),
  59. );
  60. }
  61.  
  62. $this->template->build('signup', $this->data);
  63. }
Add Comment
Please, Sign In to add comment