...

View Full Version : Retrieving form field



dlysuc
02-25-2007, 07: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;
?>
<br>
<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">
</form>


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

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



$_POST[$Check]

Fumigator
02-26-2007, 03: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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum