CodeIgniter Forums
Fatal error: Call to undefined function redirect() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Fatal error: Call to undefined function redirect() (/showthread.php?tid=44217)



Fatal error: Call to undefined function redirect() - El Forum - 08-08-2011

[eluser]jblack199[/eluser]
As per the title I am having issues with the redirect function on my script. I've looked and looked and cant figure out the issue.

in my autoload.php I've got the following:

Code:
$autoload['helper'] = array('valid_admin', 'url', 'form');

valid_admin is a custom helper, the other two are as it should be.

and here is my index.php which has been changed in the routes.php from welcome to index so that part is working fine.

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Index extends CI_Controller {
    function index () {  
            redirect('/login', 'refresh');
    }
}

and the issue i'm getting is:
Fatal error: Call to undefined function redirect() in /home/thecodes/public_html/qweeri/application/controllers/adm/index.php on line 4

any idea whats up? thanks in advance, 'cause i cant seem to see why its not working...


Fatal error: Call to undefined function redirect() - El Forum - 08-08-2011

[eluser]LuckyFella73[/eluser]
Do you have a constructor in your controller?

Code:
class Index extends CI_Controller { {

    function __construct()
    {
        parent::__construct();
    }

}

Don't now if that's the issue but you can try Wink


Fatal error: Call to undefined function redirect() - El Forum - 08-08-2011

[eluser]jblack199[/eluser]
hmm.. I hadn't gotten that far, and when i had it in the welcome.php as the main page, the redirect worked fine without it... but once I put it in, the redirect worked fine...

thanks a bunch!


Fatal error: Call to undefined function redirect() - El Forum - 08-08-2011

[eluser]LuckyFella73[/eluser]
Nice it works now!

Btw: "index" is a reserved controller-name (per CI userguide).
I guess you could get trouble using that one.