Why is the following
PHP Code:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "imageForm")) {
within the foreach loop? Surely it only needs to be checked once - unless you are expecting it to be an array(?) - that is, before the foreach.
Besides, you've already stored it as a variable
$orderID. Once you've created this variable you should refer to it further down, and not keep reverting to the original posted version.