Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function signup()
- {
- $this->load->helper('ionauth');
- if($this->ion_auth->logged_in() == true)
- {
- redirect('auth', 'refresh');
- }
- //validate form input
- $this->form_validation->set_rules('username', 'Username', 'username_check|required|xss_clean');
- $this->form_validation->set_rules('email', 'Email Address', 'email_check|required|valid_email');
- $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]');
- $this->form_validation->set_rules('password_confirm', 'Password Confirmation', 'required');
- if ($this->form_validation->run() == true)
- {
- $username = $this->input->post('username');
- $email = $this->input->post('email');
- $password = $this->input->post('password');
- $additional_data = array();
- }
- if ($this->form_validation->run() == true && $this->ion_auth->register($username, $password, $email, $additional_data))
- { //check to see if we are creating the user
- //redirect them back to the admin page
- $this->session->set_flashdata('message', "User Created");
- redirect("users", 'refresh');
- }
- else
- { //display the create user form
- //set the flash data error message if there is one
- $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
- $this->data['username'] = array(
- 'name' => 'username',
- 'id' => 'username',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('username'),
- );
- $this->data['email'] = array(
- 'name' => 'email',
- 'id' => 'email',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('email'),
- );
- $this->data['password'] = array('name' => 'password',
- 'id' => 'password',
- 'type' => 'password',
- 'value' => $this->form_validation->set_value('password'),
- );
- $this->data['password_confirm'] = array('name' => 'password_confirm',
- 'id' => 'password_confirm',
- 'type' => 'password',
- 'value' => $this->form_validation->set_value('password_confirm'),
- );
- }
- $this->template->build('signup', $this->data);
- }
Add Comment
Please, Sign In to add comment