Refactored to use pdo bind values, sanitizing input and preparing queries prior to insertion.