我有一个简单的清单表单,其中包含许多输入字段和计数器来检查它们。表单只包含几个文本字段和一些单选按钮,其值设置为conforms或notConforms:
我的代码结果有两个问题:
以下是什么问题?
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if($errCounter == 0){ // provided there are no errors found during form validation
// warn user if there is a non-conformance
if($notConforms !== 0){ ?>
<script>
if(confirm("A not-conforms 'N/C' result has been recorded for one or more inspection criteria. If this is accurate, click OK to continue.")) {
<?php echo updateDatabase(); header("location: inspectionbatch.php");?>
} else {
<?php echo updateDatabase(); header("location: inspectionbatch.php");?>
}
</script>
<?php } else {
updateDatabase(); header("location: inspectionbatch.php");
}
} else { // if errors are found during form validation, return how many errors were found
echo "Error count: " . $errCounter;
}
}
我还尝试在更新数据库的语法之后立即将header()函数放在updateDatabase()中。数据库已更新,但header()无效......