From 40a7dd1979e6e53442bafea9d745b6c9d74998f3 Mon Sep 17 00:00:00 2001 From: stiti Date: Thu, 23 May 2024 10:33:41 +0200 Subject: [PATCH] Ajout de l'inscription --- .../application/config/config.php | 2 +- .../application/controllers/Utilisateur.php | 46 ++++++++++++++ .../application/models/Utilisateur_model.php | 14 +++++ .../application/views/inscription.php | 47 ++++++++++++++ .../views/layout/header_not_logged_dark.php | 2 +- CodeIgniter-3.1.13/assets/css/inscription.css | 62 +++++++++++++++++++ 6 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 CodeIgniter-3.1.13/application/controllers/Utilisateur.php create mode 100644 CodeIgniter-3.1.13/application/models/Utilisateur_model.php create mode 100644 CodeIgniter-3.1.13/application/views/inscription.php create mode 100644 CodeIgniter-3.1.13/assets/css/inscription.css diff --git a/CodeIgniter-3.1.13/application/config/config.php b/CodeIgniter-3.1.13/application/config/config.php index 155c4a8..df7c320 100644 --- a/CodeIgniter-3.1.13/application/config/config.php +++ b/CodeIgniter-3.1.13/application/config/config.php @@ -387,7 +387,7 @@ $config['sess_driver'] = 'files'; $config['sess_cookie_name'] = 'ci_session'; $config['sess_samesite'] = 'Lax'; $config['sess_expiration'] = 7200; -$config['sess_save_path'] = NULL; +$config['sess_save_path'] = sys_get_temp_dir(); // Utiliser le répertoire temporaire du système $config['sess_match_ip'] = FALSE; $config['sess_time_to_update'] = 300; $config['sess_regenerate_destroy'] = FALSE; diff --git a/CodeIgniter-3.1.13/application/controllers/Utilisateur.php b/CodeIgniter-3.1.13/application/controllers/Utilisateur.php new file mode 100644 index 0000000..890ce25 --- /dev/null +++ b/CodeIgniter-3.1.13/application/controllers/Utilisateur.php @@ -0,0 +1,46 @@ +load->helper(array('form', 'url')); + $this->load->library(array('form_validation', 'session')); + $this->load->model('Utilisateur_model'); + } + + public function inscription(){ + // Définir les règles de validation + $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[utilisateur.email]'); + $this->form_validation->set_rules('nom', 'Nom', 'required'); + $this->form_validation->set_rules('prenom', 'Prénom', 'required'); + $this->form_validation->set_rules('telephone', 'Téléphone', 'max_length[20]'); + + if ($this->form_validation->run() == FALSE) { + // Charger la vue avec les erreurs + $this->load->view('layout/header_not_logged_dark'); + $this->load->view('inscription'); + $this->load->view('layout/footer_dark'); + } else { + // Récupérer les données du formulaire + $data = array( + 'email' => $this->input->post('email'), + 'nom' => $this->input->post('nom'), + 'prenom' => $this->input->post('prenom'), + 'telephone' => $this->input->post('telephone') + ); + + // Insérer les données dans la base de données + if ($this->Utilisateur_model->insert_user($data)) { + $this->session->set_flashdata('success', 'Inscription réussie. Vous pouvez maintenant vous connecter.'); + redirect('utilisateur/inscription'); + } else { + $data['error'] = 'Une erreur est survenue. Veuillez réessayer.'; + $this->load->view('layout/header_not_logged_dark'); + $this->load->view('inscription', $data); + $this->load->view('layout/footer_dark'); + } + } + } +} diff --git a/CodeIgniter-3.1.13/application/models/Utilisateur_model.php b/CodeIgniter-3.1.13/application/models/Utilisateur_model.php new file mode 100644 index 0000000..23cd895 --- /dev/null +++ b/CodeIgniter-3.1.13/application/models/Utilisateur_model.php @@ -0,0 +1,14 @@ +load->database(); + } + + public function insert_user($data){ + return $this->db->insert('utilisateur', $data); + } +} diff --git a/CodeIgniter-3.1.13/application/views/inscription.php b/CodeIgniter-3.1.13/application/views/inscription.php new file mode 100644 index 0000000..52baecd --- /dev/null +++ b/CodeIgniter-3.1.13/application/views/inscription.php @@ -0,0 +1,47 @@ + + + + + + Inscription + + + +
+

Inscription

+ + +

+ + + + +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + +
+ + + + +
+ + diff --git a/CodeIgniter-3.1.13/application/views/layout/header_not_logged_dark.php b/CodeIgniter-3.1.13/application/views/layout/header_not_logged_dark.php index 9287fc3..2e45c9b 100644 --- a/CodeIgniter-3.1.13/application/views/layout/header_not_logged_dark.php +++ b/CodeIgniter-3.1.13/application/views/layout/header_not_logged_dark.php @@ -29,7 +29,7 @@ Artistes Musiques Connexion - Inscription + Inscription