Refactored some code and added some validation.

Done some code reuse with the connection although i think theres an even
better way to do it... made it so fields remember the values upon
incorrect entry.