Fatal Error Call To Undefined Function Redirect_to
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings
Call To Undefined Function Wp_safe_redirect
and policies of this site About Us Learn more about Stack Overflow fatal error call to undefined function http_redirect the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation call to undefined function redirect() laravel Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it
Redirect Function In Codeigniter
only takes a minute: Sign up fatal error: call to undefined function redirect() up vote 0 down vote favorite I am using mobiledetect for redirect mobile users to a specific page. But, when I'm writing this then I am getting the Fatal error for redirect(). Can anyone please let me know where and what I'm missing? require_once 'Mobile_Detect.php'; $detect =
Codeigniter Redirect Not Working
new Mobile_Detect; $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer'); $scriptVersion = $detect->getScriptVersion(); if ($detect->isMobile()) redirect('iammobile.php'); else echo '
I am Desktop
'; php redirect share|improve this question edited Feb 17 '14 at 9:04 Rob Starling 2,34111135 asked Feb 17 '14 at 8:58 Md Mazedul Islam Khan 719717 5 redirect() is not a function. Error is fairly clear. Where are you creating this function? Do you actually want the header() function? –naththedeveloper Feb 17 '14 at 8:58 See this question for a lot of options: stackoverflow.com/questions/768431/… –Rob Starling Feb 17 '14 at 9:00 That means it couldn't find a function with a name redirect anywhere. Try using header("Location:iammobile.php") instead –asprin Feb 17 '14 at 9:00 add a comment| 4 Answers 4 active oldest votes up vote 5 down vote accepted Try with header like header("Location: iammobile.php"); die(); share|improve this answer edited Feb 17 '14 at 9:06 answered Feb 17 '14 at 8:59 Gautam3164 21.7k13757 Hi, When I used like this: if ($detect->isMobile()) header("Location: iammobile.php"); Then it shows Internal Server Ehere for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about call to undefined function base_url() in codeigniter 3 Stack Overflow the company Business Learn more about hiring developers or posting ads with
Php Redirect
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is php header a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Codeigniter redirect not working up vote 2 down vote favorite Why isn't redirect working http://stackoverflow.com/questions/21824599/fatal-error-call-to-undefined-function-redirect 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(); } } } php codeigniter share|improve this question edited Aug 16 '11 at 18:20 jondavidjohn 40.7k1390133 asked Aug 16 '11 at 18:02 amiawizard 2,14663565 http://stackoverflow.com/questions/7082795/codeigniter-redirect-not-working add a comment| 5 Answers 5 active oldest votes up vote 11 down vote accepted 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... share|improve this answer edited Aug 16 '11 at 18:09 answered Aug 16 '11 at 18:05 jondavidjohn 40.7k1390133 add a comment| up vote 2 down vote You're not loading the URL helper in the authenticate method. You'll have to either add $this->load->helper('URL') to the class constructor (which it looks like you were trying to do), or you'll have to add that to the authenticate method itself. Just a reminder, the index method is a special method -- it is called when no other method is specified. With the URL
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the http://stackoverflow.com/questions/25643694/php-redirect-to-function-undefined workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join call to them; it only takes a minute: Sign up php redirect_to() function undefined up vote -3 down vote favorite I am working on a database and I need to redirect the user to another page after the login process. I am using the redirect_to() function. After the code executes it gives me the error Fatal error: Call to undefined function call to undefined redirect_to() Here is what I tried if($result){ $num_rows = mysqli_num_rows($result); if($num_rows == 1){ $found_user=mysqli_fetch_array($result); redirect_to("main.php"); } else{ redirect_to("index.php"); } } php share|improve this question edited Sep 3 '14 at 11:59 TRiG 5,47623170 asked Sep 3 '14 at 11:57 Morteza Azmoodehafshar 357 2 It means that redirect_to doesn't exist. –Wayne Whitty Sep 3 '14 at 11:57 redirect_to isn't a PHP method, if you haven't defined that function anywhere, then it won't exist... where did you get this function from?! –RaggaMuffin-420 Sep 3 '14 at 11:58 2 There is no built in function with that name. If you wrote one yourself, its out of scope –Steve Sep 3 '14 at 11:58 header() is the function you are looking for php.net/manual/en/function.header.php –senK Sep 3 '14 at 12:01 add a comment| 6 Answers 6 active oldest votes up vote 1 down vote accepted You have to define the redirect_to function before calling it. Try this code