Honestly, your best bet is to actually use $_POST
to process this logic. In your form, your submit buttons lack a name
attribute which would allow you to do this:
<form method="post" action="http://xxx.yyy/wp-admin/admin-post.php">
<td width="60" height="26">
<input type="submit" value="Lot #" name="lot">
</td>
<td width="154" >
<input type="submit" value="Name" name="name">
</td>
<td width="154">
<input type="submit" value="Subdivision - Blk / Lot" name="subdivision">
</td>
<td width="96">
<input type="submit" value="Address" name="address">
</td>
</form>
And since the only real difference between the <td>
elements is the value of data
you can eliminate the two hidden fields.
Then in your handler you can use if
statements to check $_POST
to see which submit button was clicked with the isset()
function:
if ( isset( $_POST['lot'] ) {
$data = 1;
} elseif ( isset( $_POST['name'] ) ) {
$data = 2;
} elseif ( isset( $_POST['subdivision'] ) ) {
$data = 3;
} elseif ( isset ($_POST['address] ) ) {
$data = 4;
} else {
die( 'Invalid Selection' );
}
// Rest of your handler goes here