Hello,
Here is my form:
<form method="post" action="action_page.php">
<div id="periods" class="selector">
<p>Please select desired period:</p>
<input type="radio" name="period" value="all" checked="checked">All (default)<br><br>
<input type="radio" name="period" value="filter" id="period">From: <input type="text" class="datepicker" name="start_date"> <br>        To: <input type="text" class="datepicker" name="end_date"> <br><br>
<button type="button" id="periods-button">Clear selection</button>
</div><!-- End periods -->
<div id="days" class="selector">
<p>Select days / A Day (One day at least)</p>
<input type="checkbox" name="weekday[]" value="6" class="days"> Sunday
             
<input type="checkbox" name="weekday[]" value="0" class="days"> Monday<br><br>
<input type="checkbox" name="weekday[]" value="1" class="days"> Tuesday
           
<input type="checkbox" name="weekday[]" value="2" class="days"> Wednesday<br><br>
<input type="checkbox" name="weekday[]" value="3" class="days"> Thursday
         
<input type="checkbox" name="weekday[]" value="4" class="days"> Friday<br><br>
<button type="button" id="days-button">Clear selection</button>
</div><!-- End days -->
<div id="intraday" class="selector">
<p>Select intraday time range</p>
<input type="radio" name="intraday" value="am"> AM <small>(00:00 - 11:59)</small><br><br>
<input type="radio" name="intraday" value="pm"> PM <small>(12:00 - 23:59)</small><br><br>
<input type="radio" name="intraday" id = "hour_range">
From:<input type="time" min="00:00" max="23:59" name = "start" placeholder="00:00" value="00:00">
To : <input type="time" min="00:00" max="23:59" name = "end" laceholder="23:59"value="23:59"><br><br>
<button id="intraday-button" type="button" value="Clear selection ">Clear selection</button>
</div><!-- End intraday -->
<div class="apply"><button type="reset" value="reset form">Reset Form</button></div>
<div class="apply"><button type = "submit" value="submit" -->>Filter Results</button></div>
<div id="" style="clear:both;"></div>
</form>
Here is the action_page:
<?php
//code for period
switch ($_POST['period']) {
// filter is selected. From date selected. To date not selected
case isset($_POST['period']) == 'filter' && isset($_POST['start_date']) == true && isset($_POST['end_date']) == false:
echo '1';
break;
// filter is selected. From date selected. To date selected
case isset($_POST['period']) == 'filter' && isset($_POST['start_date']) == true && isset($_POST['end_date']) == true:
echo '2';
break;
// filter is selected. From date not selected. To date selected
case isset($_POST['period']) == 'filter' && isset($_POST['start_date']) == false && isset($_POST['end_date']) == true:
echo '3';
break;
// filter is selected. from date not selected. to date not selected
case isset($_POST['period']) == 'filter' && isset($_POST['start_date']) == false && isset($_POST['end_date']) == false:
echo '0';
break;
// Att(default) is selected.
default:
echo 'all';
}
//code for dayy
echo"<br>";
if(isset($_POST['weekday'])){
$days = ($_POST['weekday']);
print_r($days);
echo "<br><br>";
}
// code for intraday
if(isset($_POST['intraday'])){
$hours = ($_POST['intraday']);
switch ($hours) {
case "am":
$hour_start = '00:00';
$hour_end = '11:59';
echo $hour_start;
echo $hour_end;
break;
case "pm":
$hour_start = '12:00';
$hour_end = '23:59';
echo $hour_start;
echo $hour_end;
break;
case "on":
$hour_start = ($_POST['start']);
$hour_end = ($_POST['end']);
echo $hour_start;
echo $hour_end;
break;
default:
$hour_start = '00:00';
$hour_end = '23:59';
echo $hour_start;
echo $hour_end;
}
}
?>
When I check it I get wrong input from the first div in the form , the period div
when I check the second radio button without dates or with dates in either input field or both I eitherget 2 as output or all - which is the default of the switch
What do I do wrong?
P.S. the rest of the form works well