[eluser]riwakawd[/eluser]
[quote author="Tpojka" date="1402146893"]Few things before trying to solve:
1. method has no name;
2. model as represented has no that line
First block of code, if controller, has no name of method.
Error that is displayed tells that something is wrong in model.
And in Model there is no that line, so can you put things together again, please?
Also try to check if post data is opposite to FALSE. Maybe you get something.[/quote]
I have done this below but still get error Fatal error: Can't use method return value in write context in C:\xampp\htdocs\codeigniter-cms-1\admin\application\modules\backend\models\user\user_model.php on line 32
I have hmvc and added MY Form Validation
Code:
public function __construct() {
parent::__construct();
$this->load->library('form_validation');
$this->load->model('backend/user/user_model');
$this->lang->load('backend/english', 'english');
$this->lang->load('backend/common/login', 'english');
}
public function ControllerCommonLogin() {
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|callback_checkinfo');
$data['title'] = $this->lang->line('heading_title');
$data['action'] = site_url('backend/login');
if($this->form_validation->run($this) == FALSE) {
$this->load->view('template/common/login', $data);
} else {
redirect('dashboard', 'refresh');
}
}
public function validate($password) {
$username = $this->input->post('username');
//query the database
$result = $this->user_model->login($username, $password);
if($result) {
$sess_array = array();
foreach($result as $row){
$sess_array = array(
'user_id' => $row->id,
'username' => $row->username,
'ip' => $row->ip
);
$this->session->set_userdata('isLogged', $sess_array);
}
return TRUE;
} else {
$this->form_validation->set_message('checkinfo', 'Invalid username or password');
return false;
}
}
And added this library
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Form_validation extends CI_Form_validation {
function run($module = '', $group = '') {
(is_object($module)) AND $this->CI = &$module;
return parent::run($group);
}
}