Have you tried specifying these values just like you have set them on the confirm page?
$ATC_Code1 = "".$_POST['on0_'.($displayIndex+1)] ."";
$ATC_Code2 = "".$_POST['on1_'.($displayIndex+1)] ."";
If you cannot get the values when specifying them like this you may need to add in some debugging to get the values that are being sent from the post so you know what to expect on this page. To do this you can add in the following code after the isValid function call:
$the_post = ob_get_contents();
After you put this on the page you will need to record this $the_post variable is some way, you can have a UE server behavior send this value in the email message so that you can review it to determine how these values are sent back to you.