Did you update the form button name on the checkout page? Are you sure you are going to the checkout_failure.php page?
It looks like the code should not run until the button "Submit_order" is pressed.
Is it possible you updated the button on the confirm or checkout page? You may need a support incident to debug this issue since it looks correct to me. I must be missing something.