Пример #1
0
 function login()
 {
     $this->form_validation->set_rules('username', 'username', 'trim|required', '');
     $this->form_validation->set_rules('password', 'password', 'trim|required', '');
     $this->form_validation->set_error_delimiters('<div class="remember-me">', '</div>');
     if ($this->form_validation->run() == FALSE) {
         $this->load->view('index');
     } else {
         $this->load->model('model_login');
         $hash_passwd = generatePassword($this->input->post('password'));
         $result = $this->model_login->admin_login($this->input->post('username'), $hash_passwd);
         if ($result) {
             foreach ($result as $row) {
                 $this->session->set_userdata(array('logged_in' => TRUE, 'user_id' => $row->user_id, 'user_first_name' => $row->user_first_name, 'user_last_name' => $row->user_last_name, 'user_email' => $row->user_email, 'user_type' => $row->user_type));
             }
             redirect($this->config->item('base_url') . 'dashboard');
         } else {
             $this->session->set_flashdata('message', _erMsg2('<h5 style="color:red">You Have Entered  Invalid Credentials</h5>'));
             redirect($this->config->item('base_url') . 'index');
         }
     }
 }
Пример #2
0
<div class="login-container">
    <div class="well-login">
        <?php 
if (validation_errors()) {
    echo _erMsg2(validation_errors());
}
if ($this->session->flashdata('message')) {
    echo $this->session->flashdata('message');
}
?>
 
        <form method="post" action="<?php 
echo base_url() . "index/login";
?>
" >
            <div class="control-group">
                <div class="controls">
                    <div>
                        <input id="username" name="username" required type="text" placeholder="Email" class="login-input user-name">
                    </div>
                </div>
            </div>
            <div class="control-group">
                <div class="controls">
                    <div>
                        <input id="password" name="password" required type="password" placeholder="Password" class="login-input user-pass">
                    </div>
                </div>
            </div>
            <div class="clearfix">
                <button style="background:#3c8dbc none repeat-x scroll 0 0" class="btn btn-inverse login-btn" type="submit">Login</button>