Why isn't redirect working here. I'm getting call to undefined function redirect().
class Login extends CI_Controller {
function index() {
parent::__construct();
$this->load->helper('form');
$this->load->helper('url');
$this->load->view('login_view');
}
function authenticate() {
$this->load->model('user_model');
$query = $this->user_model->authenticate();
if($query) {
$data = array(
'username' => $this->input->post('username'),
'is_logged_in' => true
);
$this->session->set_userdata($data);
redirect('/site/news_feed');
}
else {
$this->index();
}
}
}
Try:
function __construct() {
parent::__construct();
$this->load->helper('form');
$this->load->helper('url');
}
If your server is windows, try:
redirect('/site/news_feed','refresh');
Change the top portion above your authenticate()
method to this...
class Login extends CI_Controller {
function __construct()
{
// this is your constructor
parent::__construct();
$this->load->helper('form');
$this->load->helper('url');
}
function index()
{
//this is only called when someone does not specify a method...
$this->load->view('login_view');
}
...
I would strongly recommend moving these two helpers to be autoloaded because of their almost manditory use...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With