Frustrating issue with checkboxes not being set

Hello.

I have a frustrating issue with checkboxes not being set. Meanwhile, the radio selections in the same form function as expected.

For example I have the following input field (corresponding to an article selection in a marketing application)

<input type="checkbox" name="13|18|100.0000"/>

And if I run var_dump ($_POST[‘13|18|100.0000’]); in my application, and having checked the field, the output is; Notice: Undefined index: 13|18|100.0000.

What could be the cause for this?

EDIT:

I should have tried a bit more, var_dumping the POST variable disclosed that the array index is 13|18|100_0000. With an underscore, for whatever reason.

There’s nothing wrong with that input box so the problem must be somewhere else in your code which I can’t see because it’s not posted

Have you checked the checkbox before submitting it? If they are not checked, they are not submitted - hence the index is undefined.

Pretty sure PHP will convert the period in that name to an underscore upon submission, it’s a PIA.

I’ve never looked into why it does this though.

Perhaps to do with variable variables?


$variableName = $_GET['my.var'];
echo $$variableName;
// syntax error? $my.var isn't a valid variable name

Found this too: http://www.php.net/manual/en/tutorial.forms.php#52539

Ok, useful to know that its a standard. What does PIA stand for?

Pain in the ass :slight_smile: