Пример #1
0
 public function login_user()
 {
     if ($this->input->post('submit')) {
         $record['username'] = $this->input->post('username');
         $record['password'] = login_lib::prepare_password($this->input->post('password'));
         $isvalid = login_lib::verify_user($record, $this->table_name);
         if ($isvalid == TRUE) {
             $username = $this->session->userdata('login_name');
             $staff_id = $this->session->userdata('login_id');
             $login = date("Y-m-d");
             /*$sql = mysql_query("select * from tbl_attendace where staff_id='$staff_id' and login_time like'$login%' ");
             		$count = mysql_num_rows($sql);
             		if($count<=0){*/
             // mysql_query("insert into tbl_attendance( staff_id, username) values('$staff_id','$username')");
             //}
             redirect(login_lib::SUCCESSFULL_LOGIN);
         } else {
             redirect(Login_lib::UNSUCCESSFULL_LOGIN);
         }
     }
     $this->load->view('login');
 }
Пример #2
0
 public function edit($user_id)
 {
     $read_write = $this->session->userdata('read_write_blocked');
     if ($read_write == '0') {
         if ($this->input->post('edit_submit')) {
             $this->form_validation->set_error_delimiters('<span class="error">', '</span><br/>');
             $this->form_validation->set_rules('username', 'Username', 'required|xss_clean');
             $this->form_validation->set_rules('new_password', 'password', 'trim|required|xss_clean');
             $this->form_validation->set_rules('recovery_email', 'Recovery Email', 'trim|required|xss_clean|valid_email');
             $this->form_validation->set_rules('re_password', 'Re Password', 'required');
             if ($this->form_validation->run() == TRUE) {
                 $some_data['username'] = $this->input->post('username');
                 $some_data['password'] = login_lib::prepare_password($this->input->post('new_password'));
                 $some_data['recovery_email'] = $this->input->post('recovery_email');
                 $insert_id = $this->admin_model->update_admin($some_data, $user_id);
                 if (isset($insert_id)) {
                     $this->session->set_flashdata('message', 'Data successfully Added !');
                     redirect('admin/');
                 }
             }
         }
         $this->data['title'] = "Edit User";
         $this->data['record'] = $this->admin_model->get_admin_user($user_id);
         $this->data['template'] = 'admin/edit_admin';
         $this->data['password'] = $this->input->post('new_password');
         $this->load->view('common/main', $this->data);
     } else {
         $this->data['title'] = "Add Categories";
         $this->data['template'] = 'admin/not_allowed';
         $this->load->view('common/main', $this->data);
     }
 }