I have an HTML dropdown menu that looks like this
<select name='not working random test!'>
<option value='0'>Select quantity:</option>
<option value='1'>1 room</option>
<option value='2'>2 rooms</option>
</select>
Is it even possible that, if I'm var_dumping $_POST, I see something like this?
["not_working_random_test!"]=>
string(1) "1"
This is causing some troubles with my engine: I expect the name I specify for the select to be the same. Why is this not happening?
This is standard PHP behaviour. From the documentation:
Dots and spaces in variable names are converted to underscores. For example
<input name="a.b" />becomes$_REQUEST["a_b"].
The full list of field-name characters that PHP converts to _ (underscore) is the following (not just dot):
(space). (dot)[ (open square bracket)If both an open and a closing square bracket are present, they are not converted but the $_POST element becomes an array element.
<input name='hor[se'>
<input name='hor[se]'>
will become:
$_POST['hor_se'];
$_POST['hor']['se'];
::Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With