Hi
I am selecting wdays1 checkbox is checked and remaining checkbox is unchecked after submitting, i am getting an error message as below can any one please help me to resolve the issue
Error
1 Notice: Undefined index: wdays2 in C:\xampp\htdocs\smart\checkvalue.php on line 10 0 Notice: Undefined index: wdays3 in C:\xampp\htdocs\smart\checkvalue.php on line 14 0 Notice: Undefined index: wdays4 in C:\xampp\htdocs\smart\checkvalue.php on line 18 0 Notice: Undefined index: wdays5 in C:\xampp\htdocs\smart\checkvalue.php on line 22 0 Notice: Undefined index: wdays6 in C:\xampp\htdocs\smart\checkvalue.php on line 26 0 Notice: Undefined index: wdays7 in C:\xampp\htdocs\smart\checkvalue.php on line 30 0
Code:
<?php
if(isset($_POST['Submit']))
{
if($_POST['wdays1']=='')
echo $wdays1v = 0;
else
echo $wdays1v = 1;
if($_POST['wdays2']=='')
echo $wdays2v = 0;
else
echo $wdays2v = 1;
if($_POST['wdays3']=='')
echo $wdays3v = 0;
else
echo $wdays3v = 1;
if($_POST['wdays4']=='')
echo $wdays4v = 0;
else
echo $wdays4v = 1;
if($_POST['wdays5']=='')
echo $wdays5v = 0;
else
echo $wdays5v = 1;
if($_POST['wdays6']=='')
echo $wdays6v = 0;
else
echo $wdays6v = 1;
if($_POST['wdays7']=='')
echo $wdays7v = 0;
else
echo $wdays7v = 1;
}
<form action="checkvalue.php" method="post" enctype="multipart/form-data">
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays1" name="wdays1" value='1'>
Monday </div>
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays2" name="wdays2" value='1'>
Tuesday </div>
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays3" name="wdays3" value='1'>
Wednesday </div>
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays4" name="wdays4" value='1'>
Thursday </div>
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays5" name="wdays5" value='1'>
Friday </div>
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays6" name="wdays6" value='1'>
Saturday </div>
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays7" name="wdays7" value='1'>
Sunday </div>
<input name="Submit" type="submit" value="Submit">
</form>