Fix Multiple XSS Issues 

Also, not exactly sure why you are using `isset()` and `empty()` that way as it should be checked before passing it to the function as it will error with 'undefined index' because you are trying to use it in function call when the variable may not be set.