There are a few places in this method that $_POST is used as local variable. In my opinion, $_POST should always be treated as a reserved global variable where its content is only for keeping information of the post request rather than being manipulated as a local variable. Use local defined variables if manipulation is required.

I know these are old code you inherited and you are not the initial author, geetashi. Let's take this chance to improve our code. Thanks for helping out.