application/controllers/Users.php
/*DOCU This function is triggered when the clicks the add user button. 
	Checks if the entered fields are valid, alerts the user for any error on the form
	Owner:Philip */
DOCU This function is triggered when the clicks the add user button.
Checks if the entered fields are valid, alerts the user for any error on the form
Owner:Philip
DOCU This function is triggered when the clicks the add user button . Checks if the entered fields are valid alerts the user for any error on the form Owner : Philip
public function add_user () {
		$this->form_validation->set_rules("email", "Email", "required|valid_email");
		$this->form_validation->set_rules("first_name", "First name", "required|min_length[3]");
		$this->form_validation->set_rules("last_name", "Last name", "required|min_length[2]");
		$this->form_validation->set_rules("password", "Password", "required|min_length[6]|matches[confirm]");
		$this->form_validation->set_rules("confirm", "Confirm password", "required|matches[password]");
		if ($this->form_validation->run() == FALSE) {
			$this->session->set_flashdata("email_taken", "");
			$this->load->view('admin/add');
		}
		else {
			$email = $this->input->post("email");
			$user = $this->user->get_user_by_email($this->security->xss_clean($email));
			if(empty($user)) {
				$password = $this->security->xss_clean($this->input->post("password"));
				$data = array(
					"email" => $this->security->xss_clean($email),
					"first_name" => $this->security->xss_clean($this->input->post("first_name")),
					"last_name" => $this->security->xss_clean($this->input->post("last_name")),
					"user_level" => "user",
					"password" => md5($password)
				);
				$this->user->save_user($data);
				redirect("admin");
			}
			else {
				$this->session->set_flashdata("email_taken", "Email already taken!");
				$this->load->view('admin/add');
			}
		}
	}
public function add_user ( ) { $ this -> form_validation -> set_rules ( " email " , " Email " , " required|valid_email " ) ; $ this -> form_validation -> set_rules ( " first_name " , " First name " , " required|min_length[3] " ) ; $ this -> form_validation -> set_rules ( " last_name " , " Last name " , " required|min_length[2] " ) ; $ this -> form_validation -> set_rules ( " password " , " Password " , " required|min_length[6]|matches[confirm] " ) ; $ this -> form_validation -> set_rules ( " confirm " , " Confirm password " , " required|matches[password] " ) ; if ( $ this -> form_validation -> run ( ) == FALSE ) { $ this -> session -> set_flashdata ( " email_taken " , " " ) ; $ this -> load -> view ( 'admin/add' ) ; } else { $ email = $ this -> input -> post ( " email " ) ; $ user = $ this -> user -> get_user_by_email ( $ this -> security -> xss_clean ( $ email ) ) ; if ( empty ( $ user ) ) { $ password = $ this -> security -> xss_clean ( $ this -> input -> post ( " password " ) ) ; $ data = array ( " email " => $ this -> security -> xss_clean ( $ email ) , " first_name " => $ this -> security -> xss_clean ( $ this -> input -> post ( " first_name " ) ) , " last_name " => $ this -> security -> xss_clean ( $ this -> input -> post ( " last_name " ) ) , " user_level " => " user " , " password " => md5 ( $ password ) ) ; $ this -> user -> save_user ( $ data ) ; redirect ( " admin " ) ; } else { $ this -> session -> set_flashdata ( " email_taken " , " Email already taken! " ) ; $ this -> load -> view ( 'admin/add' ) ; } } }
DOCU This function is triggered when the clicks the add user button.
DOCU This function is triggered when the clicks the add user button .