I think that maybe the problem isn't on the PHP side. Perhaps, the submit function is the source of the problem. I have had experiences in the past in which if a page was being submitted, it would "submit again" which would cause it to send 2. Try a js function to make sure that only one request is being performed at a time.