Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Login extends CI_Controller {
- function __construct() {
- parent::__construct();
- $this->load->model('login_model');
- }
- public function index() {
- //check if i can pass some data to view
- $data['title_header'] = 'Login title';
- $this->load->view('foundation/header', $data);
- //security inputs in controller, if some data are sents
- $this->check_login();
- //loading login page
- $this->load->view("login_view");
- $this->load->view('foundation/footer');
- }
- private function check_login() {
- //check if is not empty
- if (!$this->input->post('username') && !$this->input->post('password')) {
- return;
- }
- //if i have some value i begin the test...
- $this->load->library('form_validation');
- $this->form_validation->set_rules('username', 'Name', 'required|max_length[20]');
- $this->form_validation->set_rules('password', 'Password', 'required|max_length[20]');
- //
- if ($this->form_validation->run()) {
- //if everything is ok, let's check in db
- $params = array(
- 'username' => $this->input->post('username'),
- 'password' => $this->input->post('password'),
- /* and username and password is secure by form validation? */
- );
- $this->login_model->check_login_database($params);
- } else {
- //how i know what is wrong?name or password?i'm confuse
- $this->session->set_flashdata('login', array('class' => 'alert alert-danger', 'message' => 'Something is wrong'));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement