<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class InscriptionController extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->helper(array('url', 'html'));
    }

    public function inscription() {
        $this->load->view('layout/header');
        $this->load->view('connexion');
        $this->load->view('layout/footer');
    }

    public function traitement() {
        if(isset($_POST['ok'])){
            $this->load->database();
    

            $prenom = ucfirst(strtolower($this->input->post('prenom')));
            $nom = strtoupper($this->input->post('nom'));
            $pseudo = $this->input->post('pseudo');
            $mdp = $this->input->post('pass');
            $email = $this->input->post('email');
    
            $data = array(
                'pseudo' => $pseudo,
                'nom' => $nom,
                'prenom' => $prenom,
                'mdp' => $mdp,
                'email' => $email
            );
    
            $this->db->insert('users', $data);
    
            $data['confirmation_message'] = "Inscription réussie ! Vous êtes maintenant inscrit.";

            $this->load->view('layout/header');
            $this->load->view('connexion', $data);
            $this->load->view('layout/footer');
        }
    }
    

}