added isset solution for undefined index error in PHP
set error codes and required fields and meaningful errors echo out