• Register
0 votes
448 views

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
redirect('site/function1');

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

Hope this solution helps you too.

5 2 1
4,980 points

Related questions

0 votes
1 answer 70 views
70 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 12 views
0 votes
1 answer 41 views
41 views
I am beginner on CodeIgniter, and while i go on run into problems that, defining global variable in codeigniter controller.
asked Sep 26, 2020 Daniel Anderson 4k points
0 votes
1 answer 12 views
12 views
In this case specifically i want to know how load the views via controller
asked Sep 16, 2020 Daniel Anderson 4k points
0 votes
1 answer 266 views
266 views
Problem: I am trying to insert the check box values into my database which are separated by commas. I have basic knowledge of database. But my actual problem is I need to get back my checked values from my database in order to edit relevant code. So my question is ... =>implode(",", $Specilized_category),);   $this->db->insert('tbl_employer', $data); } Kindly help me if you are codeigniter expert.
asked Jul 2, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 11 views
11 views
This issue appears in the server after i upgrading PHP and also i am obtaining the following error with PHP Version 5.6.2 on Apache 2.0. Why this is happening in my case and how to solve it.
asked Sep 14, 2020 Daniel Anderson 4k points
0 votes
1 answer 35 views
35 views
Problem : I have recently upgraded my PHP on Apache. Before upgrading everything was good. But after I upgraded my server PHP I am regularly facing the below error with my latest PHP Version 5.6.2 on Apache 2.0. A PHP Error was encountered Severity: Notice Message ... returned by reference Filename: core/Common.php Line Number: 257 What could have caused the above error? How can I fix this error?
asked Feb 14, 2020 mphil 2.3k points
0 votes
1 answer 32 views
32 views
Problem When I try to upload an image using codeigniter, regardless of what I do, I end up with: You did not select a file to upload error. Please help fixing this error
asked Nov 3, 2020 hashq 1.1k points
0 votes
1 answer 91 views
91 views
I have been stuck to sort out this issue for a long time and even after reading a number of posts. Can some one help to sort out this issue and give me the reason why this is happening in this case?
asked Sep 14, 2020 Daniel Anderson 4k points