$http_post_vars

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ahmetbm
    New Member
    • Nov 2007
    • 9

    #1

    $http_post_vars

    Hi all:

    $products_quant ity = $HTTP_POST_VARS['bulk_products_ quantity'.$i];

    " 'bulk_products_ quantity'.$i " is the name of the textbox, it is getting the value of textbox via it's name field, i am trying to do it via id field, i will give same name " 'bulk_products_ quantity'.$i " to id field, any helps please...
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi. Welcome to TSDN.

    First of all, I'd like to point you in the direction of our Posting Guidelines, specifically the part about How to ask a question, where you will find several rules your post is violating.
    Please try to follow these guidelines when posting in the future.

    Moving on to your question...

    The $HTTP_POST_VARS array is old and deprecated. You should use the $_POST super-global instead:
    [code=php]
    # Replace
    $HTTP_POST_VARS['myField'];

    # With
    $_POST['myField'];
    [/code]

    The name of an element in the POST data is the value of the 'name' property in the <input> tag, not the 'id' property. There is (should) not be a way to use the 'id' property as the name of an <input> field.

    If you want to pass multiple fields using the same name, like if you want to pass an undetermined amount of fields, you can add a [] to the name and PHP will treat it as an array.

    For example, you could do this:
    [code=php]
    <?php
    # Verify that the form has been submitted
    if(isset($_POST['myField'])) {
    # Set up the index counter
    $index = 0;

    # Print each element of the 'myField' field array
    foreach($_POST['myField'] as $field) {
    echo "myField[{$index}] = {$field}<br />";
    $index++;
    }
    }
    ?>
    <form action="?" method="POST">
    <input type="text" name="myField[]" /><br />
    <input type="text" name="myField[]" /><br />
    <input type="text" name="myField[]" /><br />
    <input type="text" name="myField[]" /><br />
    <input type="text" name="myField[]" /><br />
    <input type="submit" />
    </form>
    [/code]

    Comment

    • ahmetbm
      New Member
      • Nov 2007
      • 9

      #3
      thakns for reply, when you said that i can not do it with id, i changed my javascript and solved problem.

      Thanks

      Comment

      Working...