As you know, if you have a form containing
<select name="user">
<option value="a">a</option>
<option value="b">b</option>
</select>
<input type="text" name="user[name]" />
<input type="password" name="user[password]" />
And you submit that form, in PHP, $_REQUEST['user'] will automatically become an array containing the keys name and password, and the value of the select will be gone. The opposite occurs if the <select> is moved after the other two fields. $_REQUEST['user'] will contain the value of the select, and the values in the inputs will be gone, with nothing being set to either $_REQUEST['user[name]'] or $_REQUEST['user[password]'].
To my knowledge, the same applies to $_POST, $_GET and $_FILES.
Also, input streams are unavailable when the form's MIME is multipart/form-data.
So, is there any way to disable this automatic parsing?
A. change
<select name="user">
to
<select name="user[user]">
That way you have a key set for the user array. If you are going to use post arrays you have to make sure every single one has a key.
B. (the way i'd do it)
Forget about the arrays. Use a unique name for each one. Using the arrays give you no benefit. Call the first one user, the second one, user_name, and the 3rd "password"
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