这是代码的一部分,它让我无法登录,不知道问题出在哪里。当我尝试登录时,它没有任何效果。对不起,我的英语不好。
public function login()
{
if ($this->identity->is_admin())
redirect('admin/dashboard');
if ($this->identity->is_contestant())
redirect('contestant/dashboard');
$this->form_validation->set_rules('form[username]', $this->lang->line('username'), 'trim|required|max_length[50]');
$this->form_validation->set_rules('form[password]', $this->lang->line('password'), 'trim|required|max_length[50]');
if ($this->form_validation->run())
{
$credentials = $this->input->post('form');
if ($this->identity->login($credentials))
{
if ($this->identity->is_admin())
redirect('admin/dashboard');
else
redirect('contestant/dashboard');
}
else
{
$this->session->set_flashdata('error', $this->lang->line('wrong_credentials'));
redirect('site/login');
}
}
else
{
$this->ui['header']['title'] = $this->lang->line('login');
$this->ui['header']['page'] = 'login';
$this->load->view('site/header', $this->ui['header']);
$this->load->view('site/login', $this->ui['content']);
$this->load->view('footer', $this->ui['footer']);
}
}
以下是登录网站源代码。
<div class="container">
<div class="row">
<div class="col-md-12">
<ul class="breadcrumb">
<li>
<i class="glyphicon glyphicon-off"></i> <?php echo $this->lang->line('please_login'); ?>
</li>
</ul>
</div>
</div>
<?php if ($this->session->flashdata('error')) : ?>
<div class="row">
<div class="col-md-5">
<div class="alert alert-danger">
<?php echo $this->session->flashdata('error'); ?>
</div>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col-md-12">
<form class="form-horizontal" action="" method="post">
<div class="form-group<?php echo form_error('form[username]') ? ' has-error' : ''; ?>">
<label class="col-sm-1 control-label"><?php echo $this->lang->line('username'); ?>:</label>
<div class="col-sm-4">
<input name="form[username]" type="text" maxlength="30" class="form-control" value="<?php echo set_value('form[username]'); ?>" autofocus="on"/>
<span class="help-block"><?php echo form_error('form[username]'); ?></span>
</div>
</div>
<div class="form-group<?php echo form_error('form[password]') ? ' has-error' : ''; ?>">
<label class="col-sm-1 control-label"><?php echo $this->lang->line('password'); ?>:</label>
<div class="col-sm-4">
<input name="form[password]" type="password" maxlength="30" class="form-control"/>
<span class="help-block"><?php echo form_error('form[password]'); ?></span>
</div>
</div>
<div class="form-actions col-sm-offset-1">
<button type="submit" class="btn btn-danger col-sm-3"><i class="glyphicon glyphicon-user"></i> <?php echo $this->lang->line('login'); ?></button>
</div>
</form>
</div>
</div>
是不是CI 3.0.0不支持php7.1所以错误发生了?