In my website, all pages which are visible to the user include 3 major files:
the top part in page_header.php
The bottom is page_footer.php
The middle is the page content.
In thr error_log file I constantly get the warning:
PHP Warning: session_start(): Session cannot be started after headers have already been sent in /home4/traderan/public_html/pages/page_header.php on line 2
Here is the content of page_header.php ( the upper part):
<?php
session_start();
if(isset($_SESSION['user_id']) && !empty($_SESSION['user_id'])){
$user_id = $_SESSION['user_id'];
//Get user data from DB
require 'includes/fetch.php';
``
I also get it here:
> PHP Warning: Cannot modify header information - headers already sent by (output started at /home4/traderan/public_html/includes/reset_request.inc.php:77) in /home4/traderan/public_html/includes/reset_request.inc.php on line 78
Here is file content:
mail($to, $subject, $message, $headers);
header('Location: ../reset_notice.php'); //This is line 78
exit();
I uploaded the file in case you want to see it:
reset_request.inc.php (2.6 KB)
the process stops at this file, Here is a screenshot:
When I refresh the page the header() command is processed and the page is redirected to target page
Do I use header correctly?
I searched the web for solutions for the problem but when I found a sulution e.g. ob_start(), I also found an explanation that this hides the problem - not solving it.
How do I find the source of the problem ?