在下面的代码中,我在我的数据库中使用了 codeigniter,我有一个列名 account_status,默认情况下它将处于非活动状态。现在我想检查 account_status 如果它处于活动状态,它应该让我登录,否则不要。请帮我做。
控制器:
function index()
{
$data['main_content'] = 'login_form';
$this->load->view('includes/template', $data);
}
function validate_credentials()
{
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if($query) // if the user's credentials validated...
{
$data = array(
'username' => $this->input->post('username'),
'is_logged_in' => true
);
$this->session->set_userdata($data);
redirect('site1/members_area');
}
else // incorrect username or password
{
$this->index();
}
}
站点1
function members_area()
{
$this->load->view('homepage_view');
}
模型:
function validate()
{
$this->db->where('username', $this->input->post('username'));
$this->db->where('password', md5($this->input->post('password')));
$query = $this->db->get('membership');
if($query->num_rows == 1)
{
return true;
}
}