diff --git a/application/config/autoload.php b/application/config/autoload.php index 7cdc901..af93112 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -58,7 +58,7 @@ | | $autoload['libraries'] = array('user_agent' => 'ua'); */ -$autoload['libraries'] = array(); +$autoload['libraries'] = array('database'); /* | ------------------------------------------------------------------- @@ -89,7 +89,7 @@ | | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = array(); +$autoload['helper'] = array('form','url'); /* | ------------------------------------------------------------------- @@ -132,4 +132,4 @@ | | $autoload['model'] = array('first_model' => 'first'); */ -$autoload['model'] = array(); +$autoload['model'] = array('compte_model'); diff --git a/application/config/config.php b/application/config/config.php index 58e1d3a..056dfa1 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -23,7 +23,7 @@ | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = 'http://localhost:1024/m-okapi/'; +$config['base_url'] = 'http://localhost/m-okapi/'; /* |-------------------------------------------------------------------------- diff --git a/application/config/database.php b/application/config/database.php index d22321e..4493190 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -76,9 +76,9 @@ $db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', - 'username' => '', + 'username' => 'root', 'password' => '', - 'database' => '', + 'database' => 'mokapi', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, diff --git a/application/config/routes.php b/application/config/routes.php index c414445..f6927ae 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -49,6 +49,6 @@ | Examples: my-controller/index -> my_controller/index | my-controller/my-method -> my_controller/my_method */ -$route['default_controller'] = 'mokapi'; +$route['default_controller'] = 'MOkapi'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; diff --git a/application/controllers/MOkapi.php b/application/controllers/MOkapi.php index e35749c..0131674 100644 --- a/application/controllers/MOkapi.php +++ b/application/controllers/MOkapi.php @@ -1,10 +1,63 @@ load->view('mokapi_home.php'); +class MOkapi extends CI_Controller{ + + /*============================================================================= + ICI LE CONSTRUCTEUR DE LA CALSS + ===============================================================================*/ + function __construct(){ + parent::__construct(); + } + /*============================================================================= + ICI ACTION DE LA CLASSE REPRESENTANT DE LA MAIN PAGE + ===============================================================================*/ + public function index(){ + $this->load->view('user/main'); + } + public function form_inscription(){ + $this->load->view('user/mokapi_home'); + } + public function form_auth(){ + $this->load->view('user/auth'); + } + /*============================================================================= + ICI L'ACTION DE CREATION D'UN COMPTE + ===============================================================================*/ + + public function Create_Account(){ + + $name_user = strip_tags($this->input->post('nom')); + $email_user = strip_tags($this->input->post('email')); + $pseudo_user = strip_tags($this->input->post('pseudo')); + $pass_user = $this->input->post('pwd'); + $confirm_pass_user = $this->input->post('pwdc'); + if ($pass_user == $confirm_pass_user && filter_var($email_user,FILTER_VALIDATE_EMAIL)) { + $verify_user_exist = $this->compte_model->Sign_In_User($pseudo_user,$pass_user); + if ($verify_user_exist == false) { + + $this->compte_model->Create_Account_User($name_user,$email_user, $pseudo_user, $pass_user); + echo "VOUS AVEZ CREE UN COMPTE ET BIENVENU CHEZ NOUS!"; + } + }else{ + redirect($_SERVER['HTTP_REFERER']); + } + } + + /*============================================================================= + ICI L'ACTION DE SE LOGER + ===============================================================================*/ + public function Login_In_Account(){ + + $pseudo_user = strip_tags($this->input->post('pseudo')); + $pass_user = $this->input->post('pwd'); + $user = $this->compte_model->Sign_In_User($pseudo_user,$pass_user); + if($user){ + echo "vous etes bien sur votre compte!"; + }else{ + redirect($_SERVER['HTTP_REFERER']); + } } -} \ No newline at end of file +} + + \ No newline at end of file diff --git a/application/models/Compte_model.php b/application/models/Compte_model.php new file mode 100644 index 0000000..66a9944 --- /dev/null +++ b/application/models/Compte_model.php @@ -0,0 +1,44 @@ +db->set('nomcomplet',$nom_user); + $this->db->set('login',$pseudo_user); + $this->db->set('email',$email_user); + $this->db->set('mdp',$password_user); + $this->db->set('etat',1); + return $this->db->insert($this->table_user); + + } + /*============================================================================= + ICI L' ACTION DE SE LOGER + ===============================================================================*/ + public function Sign_In_User($login ='', $pass =''){ + + $query = $this->db->where(['login'=>$login,'mdp'=>$pass])->get($this->table_user)->result(); + if( $query == true){ + return true; + }else{ + return false; + } + } + + + } \ No newline at end of file diff --git a/application/views/mokapi_home.php b/application/views/mokapi_home.php deleted file mode 100644 index 1a7703f..0000000 --- a/application/views/mokapi_home.php +++ /dev/null @@ -1,17 +0,0 @@ - - - - -
-- Votre gestionnaire de budget optimisé -
- - diff --git a/application/views/user/auth.php b/application/views/user/auth.php new file mode 100644 index 0000000..0665647 --- /dev/null +++ b/application/views/user/auth.php @@ -0,0 +1,11 @@ + +