I'll try to rephrase it, maybe I wasn't very clear. I want to retrieve variables from a form. I do something like:
$login = $_POST['login'];
Later on, I use header("Location: whatever"). Then I get the annoying "headers already sent" message. Obviously no headers should be sent, since I am careful to output everything at the end of the file, past the processing.
There is a PHP function called headers_sent() that checks whether headers have been sent or not. When I place it just before that line above I receive false, when I place it after it I receive true. It makes no sense but such is the case.
Note that the form and its processing are on the same file/page, so that if some input is not correct it calls itself again, filling in the correct fields and asking for the missing ones. It only fails when everything's correct and I reach the redirect code; the rest of the code seems correct. Weird indeed, I'm at a loss. (I'm an autodidact PHP programmer, not an expert but not a total newbie either).