So i am trying to recieve a value after a form is submitted to see if checkboxes where selected and if they wernt values would be changed in a file and another file would grab it and check to see if a value was set to display a “you need to select checkbox” message
here is code for the checkboxes——————-
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>
Here is insert file
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
Here is checkvalidation file ——————-
<?php
$setError = 0;
echo $setError;
?>
So pretty much i am trying to get a value that is changed during a form submission proccess so i can display a message as to why the form was not submitted
UPDATED ________________ $setError is always 0
here
$setError is not transport to test.php,you should find a way(get or post)to send it to test.php