使用包含文件方法,并且未设置值 - php


Using include file method and a value is not getting set - php

所以我正在尝试在提交表单后接收一个值,以查看复选框是否被选中,以及它们是否会在文件中更改值,另一个文件会抓取它并检查值是否设置为显示"您需要选择复选框"消息

下面是复选框的代码-------------------

include 'checkvalidation.php';

            CODE
<form action="insert.php" method="post">
            <input type="checkbox" value"On" name="only-thisform"/>I will complete the insurance verification form only. 
            <?php 
             echo $setError;
            if ($setError == 1){
                echo "please Check box before continuing.";
            }
             ?>
            <br>
            <br>
            <input type="checkbox"  value="On" name="approval" id="approval"/>I agree to authorize PCG Protects, LLC to receive a certificate of liability and or to be added as an additional interest on my personal auto policy, whichever accommodates my Auto Insurance Carriers standard practice, so they can monitor the active status of my personal auto policy, on behalf of my employer.
             <?php 
             if ($setError == 1){
                echo "please Check box before continuing.";
             }
             ?>
            <br>
            <br>
  CODE
    </form>

这是插入文件

include 'checkvalidation.php';
CODE
    /***************************************VALIDATE CHECK BOXES ARE CHECKED *********************************************************/
            $ch1 = 'unchecked';
            $ch2 = 'unchecked';
        //  print_r("testing ch1 : $ch1");
            if(isset($_POST['only-thisform']))  {
                $ch1 = 'Check';
                //if ($setChecker != 1)
                $setError= 0;
                //print_r("testing ch1: $ch1");
            }
            if ($ch1 !='Check' ){
            $setError = 1;
            header("Location: test.php");
            exit;
        }
            if (isset($_POST['approval'])) {
                //$setChecker = 1;
                $ch2 = 'Check';
                $setError= 0;
                //print_r("testing  ch2: $ch2");
            }
             if ($ch2 != 'Check' ){
            $setError = 1;
            header("Location: test.php");
            exit;
        }
/***************************************************************************************************************************************/           
          CODE

这是检查验证文件-------------------

<?php 


             $setError = 0;

            echo $setError; 

?>

因此,我几乎正在尝试获取在表单提交过程中更改的值,以便我可以显示有关表单未提交原因的消息

已更新 ____ $setError始终为 0

这里

$setError = 1;
header("Location: test.php");

$setError不是传输测试.php,您应该找到一种方法(获取或发布)将其发送到测试.php