在下面的codeigniter代码中我放置了控制器,如果我输入无效的用户名或密码,它显示非活动用户请联系管理员,但我想显示invalisd用户名或密码。请帮我解决问题。
控制器:
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();
}
}
答案 0 :(得分: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();
}
}
如果您仍然无法向我显示查询,那么我可以帮助您。