1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| function add_user(){
$this->load->view('user_add_new');
//$this->output->enable_profiler(TRUE);
//chargement de la librairie pour la validation du formulaire
$this->load->library('form_validation');
//Récupérer les données saisies envoyées en POST
$nom = $this->input->post('nom');
$prenom = $this->input->post('prenom');
$nom_societe = $this->input->post('nom_societe');
$mail = $this->input->post('mail');
$this->form_validation->set_rules('nom', '"Nom"', 'trim|required|alpha_dash|xss_clean');
$this->form_validation->set_rules('prenom', '"Prenom"', 'trim|required|alpha_dash|xss_clean');
$this->form_validation->set_rules('nom_societe', '"Nom de la société"', 'trim|required|alpha_dash|xss_clean');
$this->form_validation->set_rules('mail', '"Email"', 'trim|required|alpha_dash|xss_clean');
if ($this->form_validation->run()){
$data = array(
'nom_user' => $nom,
'prenom_user' => $prenom,
'nom_societe' => $nom_societe,
'email_user' => $mail,
'date_crea' => now()
);
$this->db->insert('user', $data);
}
} |