因此,我试图在提交表单后接收一个值,以查看是否选中了复选框以及它们是否会在文件中更改值,并且另一个文件会抓住它并检查是否将值设置为显示“你需要选中复选框”消息
这是复选框的代码-------------------
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