I am working to perform if else condition on form submission (POST Method) by detecting whether (the scroll option projectcode
is selected AND the date
is entered or not) OR (the value modifieddate
is entered or not).
Based on the detection i am executing my if else conditions but things are not working.
I have a form inside in file dashboard.php
<form action='dashboardentry.php' method='post'>
<label>Project Code: </label>
<select name='projectcode'>
<option value=''>Select...</option>
<option value='COP-INT'>COP-INT</option>
</select>
<label>Date: </label>
<input type='date' name='date'>
<label>OR</label>
<label>Modified Date: </label>
<input type='text' name='modifieddate'>
<button type='submit' name='delete'>Delete Entry</button>
</form>
I basically want to check whether to perform delete operation via project code and date variable value or via modified date in my database (has entries of hours spent) and for this i done below things.
In the file dashboardentry.php
<?php
if($_SERVER['REQUEST_METHOD'] === 'POST'){
if(isset($_POST['projectcode']) AND isset($_POST['date'])){
}elseif(isset($_POST['modifieddate'])){
}else{
echo "Please Enter either Project Code or Modified Date to delete Entry";
}
?>
But my problem is that this if else is not working properly as per my expectation. plz help.