Fatal Error Call To Undefined Function Redirect Php
Contents |
here 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 redirect() laravel Stack Overflow the company Business Learn more about hiring developers or posting ads with
Redirect Function In Codeigniter
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is
Codeigniter Redirect Not Working
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
Call To Undefined Function Base_url() In Codeigniter 3
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 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 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 http://stackoverflow.com/questions/7082795/codeigniter-redirect-not-working 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 them; it only takes a minute: Sign up Codeigniter redirect method http://stackoverflow.com/questions/29762611/codeigniter-redirect-method-is-not-working is not working up vote 0 down vote favorite This is my User.php controller I am unable to use redirect method. i am working on xampp localhost ?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class User extends CI_Controller { public function __construct() { parent::__construct(); // Your own constructor code $this->load->library('Admin_layout'); $this->config->load('reg_rules'); $this->load->model('admin/user_model'); $this->load->helper('form'); $this->load->helper('url'); } public function index() { if (!$this->auth->loggedin()) { redirect('admin/login'); } } public function add(){ //if($this->input->post('submit')){ $this->form_validation->set_rules($this->config->item('reg_settings')); $data["reg_attrib"] = $this->config->item("reg_attribute"); $this->form_validation->set_error_delimiters('', ''); if ($this->form_validation->run('submit') == FALSE) { // templating $this->admin_layout->set_title('Add a User'); $this->admin_layout->view('admin/add_user',$data["reg_attrib"]); // templating } else { // Develop the array of post data and send to the model. $passw = $this->input->post('password'); $hashpassword = $this->hash($passw); $user_data = array( 'name' => $this->input->post('name'), 'gender' => $this->input->post('gender'), 'phone' => $this->input->post('contact_no'), 'email' => $this->input->post('email'), 'password' => $this
our content. View the full version with proper formatting. El Forum11-25-2010, 01:36 PM [eluser]Avril[/eluser] Hi, I'm making a small http://forum.codeigniter.com/archive/index.php?thread-36219.html login form for further use of my little project and I'm stumbling at an undefined function redirect, because I'm redirecting the user in both http://www.getcloudigniter.com/2014/06/19/php-code-igniter-session-management-and-user-login-part-2/ cases. Now, in this case the credentials of the login do validate (check within the model) and then it should redirect to my /includes/template, call to but I'm getting this error: Quote:Fatal error: Call to undefined function redirect() in /Users/avrilverhaeghen/Sites/myBudget/application/controllers/login.php on line 18 Code:
class Login extends Controller{
function validate(){
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if($query == true){
$data call to undefined = array(
'username' => $this->input->post('username'),
'is_logged_in' => true
);
$this->session->set_userdata($data);
redirect('homepage');
}else{
redirect('includes/template');
}
}
} I don't see what I'm doing wrong here, maybe the redirect is a helper or some kind that needs to be loaded? Thanks! El Forum11-25-2010, 01:51 PM [eluser]Avril[/eluser] Never mind, I found it El Forum05-20-2011, 02:12 PM [eluser]spaquet[/eluser] Was this "url" library not loaded or something else ? I do load the "url" library but I'm still facing the error so sharing with you might help me. El Forum05-20-2011, 02:14 PM [eluser]danmontgomery[/eluser] You need the url helper. Code: $this->load->helper('url'); CodeIgniter Forums > CodeIgniter Archived (from EllisLab) > Archived Development & Programming > Undefined function redirect Powered By MyBB, © 2002-2016 MyBB Group
PHP Interview Questions And Answers 19 Jul, 2015 14 Code Igniter Curso 1.1 - Introducción, instalación y primeros pasos (HD) 3 Aug, 2014 10 Responses Comments10 Pingbacks0 Viesturs Teivāns says: July 9, 2012 at 5:07 pm Great tutorial. That was exactly what i was looking for Reply Kevin Lee Chang says: September 16, 2012 at 11:00 am redirect(base_url().'login'); doesn't seem to work on me. error occured Fatal error: Call to undefined function redirect() Reply Radenko Kosic says: September 21, 2012 at 11:53 am First part of the video is in HD, but it shouldn't be, and second part is in low quality but it should be HD. I can't read the code here. Thanks. Reply Mohammed Damia says: October 2, 2012 at 12:00 pm you can download the source code at phpfacultedotcom/source_code. Reply KastuloConK says: October 16, 2012 at 10:35 pm you gotta load manually or autoload the URL Helper to call the redirect function Reply Mohammed Damia says: October 20, 2012 at 3:36 pm either method should work, and make the redirect function available. Reply jason chen says: December 17, 2012 at 10:43 am I think you need to change the config file autoload.php: $autoload[‘helper'] = array(‘url'); Reply Mohamed Alioui says: February 14, 2013 at 7:06 am Thank you jason for this quick tip, it saved me alot of time searching. Reply Gowtham Gts says: September 7, 2013 at 10:40 am please make your audio a little louder… Reply Mustafa Ali says: June 2, 2014 at 1:45 am can't hear you . Your videos are great Reply Leave a Reply Cancel reply Your email address will not be published. Required fields are marked * Name * Email * Website Comment You may use these HTML tags and attributes: