Another good lesson for @psweb is always to add form validation on both client side and server side in the action.
This way you ensure the user has entered valid input and on the server side you validate the input data of the action always before you insert it in the database.
This should be a golden rule to always follow and it is pretty easy to do with the form validator.
It will save you a lot of troubles and debugging later.