Ok this is untested - typed of top of my head, and doesn't do any form validation. But if you have a php enabled server it should work.

Have commented most of it so should be easy to follow/adapt...