Results 1 to 4 of 4

Thread: HTTP_POST_VARS question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    HTTP_POST_VARS question

    I have a form that I dynamically create text boxes and the names respectively are text1, text2, text3, etc...... to text14.

    When I click the submit button I am having issues with the $HTTP_POST_VARS code.

    I just would like to know if I can do something like the following:
    PHP Code:
    for ($iArCnt=1$iArCnt<15;$iArCnt++){
        
    $sTmp "text" $iArCnt;
        if (
    strlen($HTTP_POST_VARS($sTmp)) > 0){
          
    $arFeature($iArCnt) = $HTTP_POST_VARS($sTmp);
        } else {
          
    $arFeature($iArCnt) = "";
        }

    Basically I would like to know how I can dynamically call each text.

    Thanks in advance.

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Yes, that should be able to work, however $HTTP_POST_VARS[] is deprecated. You should use $_POST[] instead (php 4.2+).

    Try switching to $_POST[], and if it still doesn't work, get back to us and someone or I will help you figure it out.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830
    Yeah, I got it working but had some minor issues to change. Here is what I ended up with:
    PHP Code:
    for ($iArCnt=1$iArCnt<15;$iArCnt++){
        
    $sTmp "text" $iArCnt;
        if (
    strlen($HTTP_POST_VARS[$sTmp]) > 0){
          
    $arFeature[$iArCnt] = $HTTP_POST_VARS[$sTmp];
        } else {
          
    $arFeature[$iArCnt] = "";
        }

    My big mistake was using () instead of []

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by lleemon
    Yeah, I got it working but had some minor issues to change. Here is what I ended up with:
    PHP Code:
    for ($iArCnt=1$iArCnt<15;$iArCnt++){
        
    $sTmp "text" $iArCnt;
        if (
    strlen($HTTP_POST_VARS[$sTmp]) > 0){
          
    $arFeature[$iArCnt] = $HTTP_POST_VARS[$sTmp];
        } else {
          
    $arFeature[$iArCnt] = "";
        }

    My big mistake was using () instead of []
    Ah, I didn't catch that

    However, as I have previously stated, $HTTP_POST_VARS[] is deprecated and should not be used. Use $_POST[] instead.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

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



Click Here to Expand Forum to Full Width