I have a 2 line script I have been using and adjusting to redirect pages using the post method. All of a sudden I am getting "Uncaught TypeError: Cannot read property 'innerHTML'" error. This code is in a php record maintenance page where I adjust the post fields to return to the calling page after the record maintenance. This code is probably used over 70 times without getting this error. Any suggestions why I would get this now?
if($_POST['maint'] == "inventory" && $_POST['rec'] == "edit") {
$pro=$conn->query("Select caseqty From products Where idpro=" . $_POST['spro'])->fetch();
$oh=($pro['caseqty'] * $_POST['ohc']) + $_POST['ohb'];
$str=$conn->prepare("Update products Set location=:loc, onhand=:oh, barcodecase=:bcc, barcodebottle=:bcb Where idpro=:id");
$str->bindParam(':loc', $_POST['loc'], PDO::PARAM_STR);
$str->bindParam(':oh', $oh, PDO::PARAM_STR);
$str->bindParam(':bcc', $_POST['bcc'], PDO::PARAM_STR);
$str->bindParam(':bcb', $_POST['bcb'], PDO::PARAM_STR);
$str->bindParam(':id', $_POST['spro'], PDO::PARAM_STR);
$str->execute();?>
<script language='javascript'>
document.body.innerHTML += '<form id="dynForm" action="office.php" method="post"><input type="hidden" name="pg" value="office"><input type="hidden" name="spg" value="inventory"><input type="hidden" name="client" value="<?php echo $_POST['client'];?>"><input type="hidden" name="spro" value="<?php echo $_POST['spro'];?>"></form>';
document.getElementById('dynForm').submit();
</script> <?php
}