0

在下面的 codeigniter 代码中,如果我输入无效的用户名或密码,它会显示非活动用户,请联系管理员,但我想显示无效的用户名或密码。请帮助我解决问题。

控制器:

function inactive()
    {
    echo"<script>alert('In active user Please contact the administrator');</script>";
    $this->load->view('login_form'); 
    }
    function invalid()
    {
    echo"<script>alert('Invalid username or password');</script>";
    $this->load->view('login_form'); 
    }
    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
            );
            if($query->num_rows()>0){
             $status = $query->row()->account_status;}
            else {
             $status = ''; }
            if($status == 'active')
            {
               $this->session->set_userdata($data);
               redirect('site1/members_area');
            }
            else //Account In active
            {  $this->inactive();  }
        }
        else // incorrect username or password
        {
            $this->invalid();
        }
    }   
4

1 回答 1

0

尝试运行此代码:

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
        );
        if($query->num_rows()>0)
        {
            $status = $query->row()->account_status;
            if($status == 'active')
            {
               $this->session->set_userdata($data);
               redirect('site1/members_area');
            }
            else //Account In active
            {  $this->inactive();  }
        }
        else 
        {
            $this->invalid();
        }

    }
    else // incorrect username or password
    {
        $this->invalid();
    }
}

如果您仍然遇到问题,请向我展示查询,那么我可以为您提供帮助。

于 2013-11-15T05:02:11.033 回答