代码点火器也在重定向上加载相同的视图



我在登录时尝试重定向到控制器中的特定函数,它可以工作,但它加载相同的视图。 我的代码如下

class Authentication extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('Authentication_model');
$this->load->model('Common_model'); 
$this->load->library('form_validation');
}
public function index() {
if ($this->session->userdata('user_id')) { 
//If the user is Super Admin
if ($this->session->userdata('role') == 'Super Admin') {   
redirect("Admin/adminProfile");
}elseif ($this->session->userdata('role') == 'Admin') {
redirect("Outlet/outlets");
} else {   
redirect("Authentication/userProfile");
}
}
$this->load->view('authentication/login');
}
public function test() {
die('hi');
}

视图

<div class="login-box-body">
<p class="login-box-msg">Please Login</p> 
<?php echo form_open(base_url('Authentication/test')); ?>
<div class="form-group has-feedback">
<input type="text" class="form-control" name="email_address" placeholder="Email Address">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<?php if (form_error('email_address')) { ?>
<div class="alert alert-error" style="padding: 5px !important;">
<p><?php echo form_error('email_address'); ?></p>
</div>
<?php } ?>
<div class="form-group has-feedback">
<input type="password" name="password" class="form-control" placeholder="Password">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<?php if (form_error('password')) { ?>
<div class="alert alert-error" style="padding: 5px !important;">
<p><?php echo form_error('password'); ?></p>
</div>
<?php } ?>
<div class="row"> 
<!-- /.col -->
<div class="col-xs-12">
<button type="submit" name="submit" value="submit" class="btn btn-primary btn-block btn-flat">Login</button>
</div>
<!-- /.col -->
</div>
<?php echo form_close(); ?>

</div>

现在当我登录时,它会转到下面的链接

baseurl.com/Authentication/test

并再次加载相同的登录视图。请帮助我有什么问题

尝试更改此行

if ($this->session->userdata('user_id')) { 

有了这个

if ($this->session->has_userdata('user_id')) { 

相关内容

  • 没有找到相关文章

最新更新