Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Retrieving form field

    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:

    PHP Code:
    <?
    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.

  • #2
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I have found the problem. The quotes are not needed within the brackets of the $_POST variable:

    PHP Code:
    $_POST[$Check

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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:
    PHP Code:
    $_POST['name'] = 'me'//correct
    $_POST[name] = 'me'//incorrect 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •