Having some trouble trying to understand your logic I'm afraid.
Your first if statement, and second if statement appear to do the same thing (more or less in this case anyway).
Your third if statement looks for the case where the username doesnt match the database, however your fourth if statement looks for the case where the password does match the database, which seems confusing to me.
Your first line, is the require() linking to the correct page, did you mistype application perhaps?
Your fourth if statement, you use an assignment operator (=) rather than comparison (==).
if ((md5($password) == $db_password)&& (!$password == ""))
I would change this to:
if ((md5($password) == $db_password) && ($password != ""))
In general I think you need to take another look at your logic, seperate it into steps.
- Check the form was submitted
- Check the username and password fields are not blank
- Check the username exists in the database and retrieve password if it does
- Check password from form matches password retrieved from database
- If all checks are ok, then log the user in, else display error(s).
Hope this helps
James