I have a page with a form on it in which I have a series
of input fields like so (note the sub-scripted name):
<input type='text' name='rating[1]' value='1'>
<input type='text' name='rating[2]' value='2'>
<input type='text' name='rating[3]' value='3'>
How do I retrieve the submitted values in a PHP script?
For example, just trying to echo the current value
displays nothing (and there IS a value being submitted)
echo("rating[$i]=".$_POST['rating[$i]']."<br>");
Or, trying to process the fields in a loop, there's
never any value present.
for($i=1; $i<=3; $i++)
{
if($_POST['rating[$i]'] < 0)
{ do something here }
if($_POST['rating[$i]'] > 10)
{ do something else here }
etc., etc., etc.
}
Syntactically, the above statements work (there's no error
generated) but there's no value there.
What am I doing wrong?
of input fields like so (note the sub-scripted name):
<input type='text' name='rating[1]' value='1'>
<input type='text' name='rating[2]' value='2'>
<input type='text' name='rating[3]' value='3'>
How do I retrieve the submitted values in a PHP script?
For example, just trying to echo the current value
displays nothing (and there IS a value being submitted)
echo("rating[$i]=".$_POST['rating[$i]']."<br>");
Or, trying to process the fields in a loop, there's
never any value present.
for($i=1; $i<=3; $i++)
{
if($_POST['rating[$i]'] < 0)
{ do something here }
if($_POST['rating[$i]'] > 10)
{ do something else here }
etc., etc., etc.
}
Syntactically, the above statements work (there's no error
generated) but there's no value there.
What am I doing wrong?
Comment