• Register
0 votes

Problem :

I am new to CodeIgniter. The Codeigniter is raising issues about my registration model that it is sending header information before anything else. I thought that the models are there only for holding the database queries methods and nothing more. Can anybody please explain me about solution on my below error?

I am facing below error I am trying to run my php CodeIgniter project.

Cannot modify header information - headers already sent by codeigniter

8 4 2
2,300 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

People who are new to codeigniter often face this issue. Few of the Host Providers have tendency to use the PHP header(); to redirect the Site, So for those kind of specific   servers if we are using the PHP header() then it will show us above error. In the Code Igniter the redirect(); function is using the PHP header() to redirect the URL. So this is the reason behind our error.

The only solution on the error is to use the JavaScript to Solve this Issue, I have used it and it works for me as shown below.

//Normal Code to redirect

//Alternate Code to fix this issue
$myurl = 'site/function1';
window.location.href = "'.base_url().'index.php?/'.$myurl.'";

Hope this solution helps you too.

5 2 1
4,980 points

Related questions

0 votes
1 answer 97 views
Problem : When I try to lock the LOGIN button, it shows me the below error, I am unable to fix this error.I am very new in php. &ldquo;Warning cannot modify header information - headers already sent by (output started at /home/content&rdquo;
asked Jan 30, 2020 jwilliam 3.9k points
0 votes
1 answer 17 views
Problem: I need someone&rsquo;s help to fix it... warning cannot modify header information headers already sent
asked Apr 3 Ifra 34.7k points
0 votes
1 answer 3 views
Problem: I would want to show some HTML code in my WordPress page. So in my child theme functions.php, I have written an action like this one: add_action('wp', function() { if(is_admin()) { return; } $html = '<div class="home_immodvisor">'; echo $html; }); ... /www/html/wp-includes/pluggable.php on line 1299 My question is: is it the good action to hook? Or should I use another one than wp?
asked 4 days ago anika11 32k points
1 vote
1 answer 12 views
Problem: I have created a dynamic menu CMS website. I developed in a Windows system. But now uploaded it into Linux Operating system server i am getting warning & error like: message: cannot modify header information - headers already sent by
asked Feb 25 Sofia Castro 4.2k points
0 votes
1 answer 23 views
0 votes
1 answer 3 views
Problem: I am trying to start a session in PHP in order to store data about a user ID (which will be used in mySQL DB).
asked Apr 25 zayed1 58.7k points
0 votes
1 answer 5 views
Problem: CodeIgniter Error: variable references.Can any one help?
asked Apr 22 Humaira ahmed 50.7k points
0 votes
1 answer 38 views
Problem: cannot use object of type stdclass as array in codeigniter.
asked Feb 20 charles mathews 5.5k points
0 votes
1 answer 4 views
Question: I have a controller named admin,and all functions in the controller can be used if the session variable is set,so what are the best ways to check if the session is set ,when clicking each link in the page or reloading the pages... for example: if i open my admin ... , bt after that in the second tab all links a working properly so i want to check if the session is set or not... Thanks!
asked Apr 13 Atik03 26.5k points
0 votes
1 answer 3 views
Problem: When I have been created two stored procedure in my database and call it in my model. It error another function in my model. It not error the function that I call procedure. It error another function that I write raw sql in model (Codelgniter).What can I do?
asked 1 day ago sumaiya simi 43.9k points