Your problem,i met it somewhere,you could see it when you use Cookies or Session rite?Because the header() must ouput first,Is there any header output in your codes that you ouput it before sth(like cookie),so recheck both config.php and login.php.
Anywait,your codes here will make everything clearer than just guess..