This error occurs mainly when you are working PHP in Linux Servers.
Method 1
The "headers already sent" error is usually caused by having white space before or after the opening and closing PHP tags (<?php . . . ?>).
Method 2
In top of page put
ob_start();
In bottom of page put
ob_flush();