View Full Version : Retrieving form field

02-25-2007, 08:07 PM
Can someone help me with the processing of a submitted form. The form is generated with a while loop and I am using another while loop to process it, so to retrieve each group of fields I just add a number to a variable and use the variable.

Here is an example similar of what I have that demonstates the field not being retrieved as expected:

if (isset($_POST['submit'])) {
$rcount = 1;
$Check = 'P'.$rcount;
echo'Submitted String '.$Check.' = '.$_POST['$Check'];

$rcount = 1;
<form action="<? echo $_SERVER['PHP_SELF']?>" method="post">
<input type="text" name="P<? echo$rcount; ?>" size="2" maxlength="2">
<input type="submit" name="submit" value="Submit">

Can someone point me in the right direction where I am going wrong? Thanks.

02-25-2007, 11:20 PM
I have found the problem. The quotes are not needed within the brackets of the $_POST variable:


02-26-2007, 04:59 PM
Good job finding the problem... just make sure you don't extend that logic to thinking you don't need quotes when referencing a specific associative index name:

$_POST['name'] = 'me'; //correct
$_POST[name] = 'me'; //incorrect