Adding key to $_POST when submitting form

I need to add a key (with no value) to $_POST when I submit a form. This key is not from the form. I tried

$_POST = array(“$ankor”=>0);

thinking that the submit would just add the form data to the end of $_POST, but no joy as in:


 echo '<form   action="adj_width.php" method="post">';
$ankor = "a" . $counter;
$counter = $counter + 1;
echo '<a name="form_' . $ankor . '"></a>';
echo 'Width:<input name="' . $id . '" type="text" />';
$_POST = array($ankor=>0);
echo '<input type="submit" value="Submit" />';
echo '</form>'; 

How do I the key (with no value) from $ankor to $_POST?

The $_POST super global cannot be used until the form is submitted so setting it won’t do anything, the best thing you can do is use a hidden input field with no value and it will work fine.

echo '<form action="adj_width.php" method="post">';
echo '<input type="hidden" name="' . $ankor . '" value="" />';
echo '</form>';

I understand. Thanks SgtLegend.

No problem, glad to help :slight_smile: