vaujdui v2
This commit is contained in:
@@ -11,36 +11,45 @@ class Connect extends CI_Controller {
|
||||
$this->load->helper(['url', 'form']);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
public function create() {
|
||||
$this->form_validation->set_rules('nom', 'Nom', 'required');
|
||||
$this->form_validation->set_rules('prenom', 'Prénom', 'required');
|
||||
$this->form_validation->set_rules('email', 'Adresse mail', 'valid_email|required');
|
||||
$this->form_validation->set_rules('password', 'Password', 'min_length[5]|required');
|
||||
$this->form_validation->set_rules('cpassword', 'Confirmation Password', 'required|matches[password]');
|
||||
|
||||
|
||||
if ($this->form_validation->run() === FALSE) {
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('create');
|
||||
$this->load->view('layout/footer');
|
||||
} else {
|
||||
$data = array(
|
||||
'nom' => $this->input->post('nom'),
|
||||
'prenom' => $this->input->post('prenom'),
|
||||
'email' => $this->input->post('email'),
|
||||
'password' => password_hash($this->input->post('password'), PASSWORD_DEFAULT)
|
||||
);
|
||||
|
||||
if ($this->User_model->create_user($data)) {
|
||||
redirect('connect/login');
|
||||
} else {
|
||||
$data['error'] = 'Erreur lors de la création du compte. Veuillez réessayer.';
|
||||
$email = $this->input->post('email');
|
||||
if ($this->User_model->emailExists($email)) {
|
||||
$data['error'] = 'L\'adresse email est déjà utilisée.';
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('create', $data);
|
||||
$this->load->view('layout/footer');
|
||||
} else {
|
||||
$data = array(
|
||||
'nom' => $this->input->post('nom'),
|
||||
'prenom' => $this->input->post('prenom'),
|
||||
'email' => $this->input->post('email'),
|
||||
'password' => password_hash($this->input->post('password'), PASSWORD_DEFAULT)
|
||||
);
|
||||
|
||||
if ($this->User_model->create_user($data)) {
|
||||
redirect('connect/login');
|
||||
} else {
|
||||
$data['error'] = 'Erreur lors de la création du compte. Veuillez réessayer.';
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('create', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function login()
|
||||
{
|
||||
|
Reference in New Issue
Block a user