Using $post insted of raw PHP $_POST and adding additional object checks.