http://ideone.com/jsaB4
I don't know HTML, nor do I know PHP.
However, you do have very deeply-nested if-else blocks. Perhaps they are working too hard? Are they trying to do both input validation and logic?