0
I am creating a system, in which the user when registering needs to be checked before the release of access.
I have in the bank the following:
use_status => 1;
For approved users!
use_status => 2;
For users under review!
I want as long as status is 2, he can’t log in, but I can’t do this.
user_model:
public function login($email, $password) {
$this->db->limit(1);
$this->db->where('use_email', $email);
$this->db->where('use_password', $password);
$this->db->select("use_id");
$query = $this->db->get('users');
$query = $query->result();
if ($query) {
return $query[0]->use_id;
} else {
return false;
}
}
public function blockUser($status){
$status = $this->db->select('use_status');
if($status == 2){
redirect('login/out');
}
}
controller login:
public function in()
{
$email = $this->input->post('email');
$password = md5($this->input->post('password'));
$login = $this->user_model->login($email, $password);
$blockUser = $this->user_model->blockUser($status);
if($login){
$this->session->set_userdata('login', $login, $blockUser);
$data = array(
'use_date_login' => date('Y-m-d H:i:s'),
'use_last_ip' => $_SERVER['REMOTE_ADDR']
);
$this->user_model->update($data, $login);
echo "login_success";
}else{
$this->session->set_userdata('login', false);
echo "login_error";
}
}