This isn't one of the specific points you asked about, but I've developed a habit of not printing HTML code directly. I almost always build up a variable containing the result page, and then print it at the end.
in reply to "Correct" program style questions
Obviously it doesn't make any difference in this case, but in most scripts that do anything non-trivial, there are opportunities along the way for something to go wrong, in which case you want to bail out and print an error page instead of what you'd planned to return. If you've been printing pieces of your page as you go along, you can't do that.