GET, POST, Multi-Selects and the PHP nightmare
Posted: Thu Jun 09, 2005 8:40 am
When the HTML of a form has a field name 'choices' and has five checkboxes with that name, each with a different value, like this:
In PHP, without altering the HTML at all (assume that I have no control over the HTML because there will be remote forms already coded by others that submit to this script) if I look at the values through the PHP-approved method (assuming that every checkbox was checked), I see:
Where did the rest of my selections disappear to? How can I get at them? This is the question that is plaguing me.
As a minor additional frustration, what if I don't give a durn what action the form used?
Is there no axiomatic way to access the form variable regardless of method (without turning on the globals option)?
Code: Select all
<form name="e;testform"e; action="e;processor.php"e; method="e;post"e;>
<input type="e;checkbox"e; name="e;choices"e; value="e;One"e; checked="e;checked"e;>One
<input type="e;checkbox"e; name="e;choices"e; value="e;Two"e; checked="e;checked"e;>Two
<input type="e;checkbox"e; name="e;choices"e; value="e;Three"e; checked="e;checked"e;>Three
<input type="e;checkbox"e; name="e;choices"e; value="e;Four"e; checked="e;checked"e;>Four
<input type="e;checkbox"e; name="e;choices"e; value="e;Five"e; checked="e;checked"e;>Five
<input type="e;submit"e; value="e;submit"e; name="e;submit"e;>
</form>Code: Select all
<?php
$choicevalues=$_POST['choices'];
print($choicevalues); //prints 'One'
?>As a minor additional frustration, what if I don't give a durn what action the form used?
Is there no axiomatic way to access the form variable regardless of method (without turning on the globals option)?