I have written an html page with a form; <form action="" method="post">
. As you can see this form should post to the same url on which the form is placed. I am using PHP to capture the post;
if(isset($_POST['submit'])) {
// do stuff
}
In the form there is a submit button <button type="submit" name="submit">Send</button>
with the correct name attribute. If I log the post variable I get all the named fields from the form but what I do not get is the correct values of those fields.
I'll add a slightly abbreviated version of the form:
<form action="" method="post">
<table class="table my-5" id="table">
<?php foreach($parameters as $key => $value): ?>
<tr>
<td>
<h6><?= $key ?></h6>
</td>
<td>
<?php
switch($key){
case 'Origin':
echo '<select class="param" name="Origin">';
foreach($ports as $port){
echo '<option>' . $port . '</option>';
}
echo '</select>';
break;
case 'OriginDepartureDate':
echo '<input class="param" name="OriginDepartureDate" type="text" value="' . $value . '">';
break;
case 'Limit':
echo '<input class="param" data-key="Limit" name="Limit" type="text" placeholder="' . $value . '">';
break;
default:
echo '<span class="param">'. $value . '</span>';
break;
} ?>
</td>
</tr>
<?php endforeach ?>
</table>
<button type="submit" name="submit">Send</button>
</form>
And the parameters being used to build the form:
$parameters['Origin'] = null;
$parameters['OriginDepartureDate'] = null;
$orderbyArr = ['DRS','GRQ','LGG',...];
The weird thing is some values do come through but others don't, the Origin value comes through and the Limit value also, but the (not "DestinationDepartureDate" but:) OriginDepartureDate does not.
I've been looking at my code for a few days now but I can't find anything obviously wrong in the logic. If some fresh eyes can see something I do not then that would be wonderful.