0

please hw to solve below problem?

Warning: Cannot modify header information - headers already sent by (output started at /home/trojalk/public_html/includes/header.html:14) in /home/trojalk/public_html/includes/careers.html on line 15

Warning: Cannot modify header information - headers already sent by (output started at /home/trojalk/public_html/includes/header.html:14) in /home/trojalk/public_html/includes/careers.html on line 16

Warning: Cannot modify header information - headers already sent by (output started at /home/trojalk/public_html/includes/header.html:14) in /home/trojalk/public_html/includes/careers.html on line 17

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by IIM
0

Hello,

You cannot use the header() function after you have already displayed some information to the page.

You are displaying tons of info, and only after that are you using the header function().

If you want to use the header() function, you must do it before you display any output, like right at the top of the page, before you any html or any echo.

There are two sollution I can think of. A quick way is to use JavaScript to redirect you to the main page.

header("Location: index.php")

with this

echo "<script>window.location = 'index.php'</script>"; // Goes to main page

The second way to solve this is to use something called "output buffering".
I have never really played around with this, but from what I've heard, this is what it does:
It automatically hold back any information you are trying to display until the last second, and then only display it.
While the output is being held back, you have a change to use the header() function.
Right at the top

ob_start();

and right at the end of your index.php you use this function:

ob_end_flush();
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.