There's no reason to retrieve all of the users from the database; simply use a WHERE clause to only get the user whose username is equal to what was entered, and you'll no longer need to go through the while loop. In addition, you'll only need to retrieve the password.
md5 could be insecure, you might want to consider using sha1 as the password hashing function.
Headers could cause problems, as they're known to be picky in where they're placed. You'll probably want to exit() right after you place the header call, to make sure secret data doesn't get accidentally shown.
If you have the secret data coming right after the login is validated, you might want to switch the if statement around, so it checks to see if the passwords are not identical, and then send the header and exit. This way, you wouldn't actually need an else statement in there.
If you want to make sure the session is empty at the start (and this is only being run once per login, not on every script), then run session_destroy() right after session_start().