Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
/* This will give an error. Note the output
* above, which is before the header() call */
to fix this problem I would suggest doing the login on another page. for example, when the user clicks the login link, it brings the user to login_verify.php and in that page verify and redirect to your desired page, and make sure that the header comes before any HTML. hope this helps