dynamic $_POST - help please

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mr_burns

    dynamic $_POST - help please

    Hi there,

    I am tryin to use a $_POST variable but the name of the form element
    is dynamic. Below is the code I am tryin but is obviously wrong as it
    isnt working:


    $abc = $_POST['abc_' . $value]; //isnt working as is


    If $value had a value of 44, the above code would be represented as:


    $abc = $_POST['abc_44'];


    As I require that the line be quite generic to whatever the value of
    $value is, I need to do it like the first snippet. What is the correct
    way of writting this? Cheers

    Burnsy
  • Alan Little

    #2
    Re: dynamic $_POST - help please

    Carved in mystic runes upon the very living rock, the last words of
    mr_burns of comp.lang.php make plain:
    [color=blue]
    > I am tryin to use a $_POST variable but the name of the form element
    > is dynamic. Below is the code I am tryin but is obviously wrong as it
    > isnt working:
    >
    >
    > $abc = $_POST['abc_' . $value]; //isnt working as is[/color]

    There's no reason that shouldn't work, assuming there actually is a key in
    $_POST with that value. Why not try dumping it and see?

    --
    Alan Little
    Phorm PHP Form Processor

    Comment

    • Ken Robinson

      #3
      Re: dynamic $_POST - help please


      mr_burns wrote:[color=blue]
      > Hi there,
      >
      > I am tryin to use a $_POST variable but the name of the form element
      > is dynamic. Below is the code I am tryin but is obviously wrong as it
      > isnt working:
      >
      >
      > $abc = $_POST['abc_' . $value]; //isnt working as is
      >
      >
      > If $value had a value of 44, the above code would be represented as:
      >
      >
      > $abc = $_POST['abc_44'];
      >
      >
      > As I require that the line be quite generic to whatever the value of
      > $value is, I need to do it like the first snippet. What is the[/color]
      correct[color=blue]
      > way of writting this? Cheers[/color]

      That should work.

      What isn't working? Dump your $_POST array and see if what you're
      looking for is really there.
      Show us the real code that isn't working. Or a URL of an example.

      Ken

      Comment

      • Pedro Graca

        #4
        Re: dynamic $_POST - help please

        mr_burns wrote:[color=blue]
        > I am tryin to use a $_POST variable but the name of the form element
        > is dynamic. Below is the code I am tryin but is obviously wrong as it
        > isnt working:
        >
        >
        > $abc = $_POST['abc_' . $value]; //isnt working as is[/color]

        Why isn't it working?
        What did you expect that to put into $abc?
        What did that put into $abc?
        How did you test?

        Post some more code, please.

        The reason that is not working /may be/ something else ...

        --
        Mail sent to my "From:" address is publicly readable at http://www.dodgeit.com/
        == ** ## !! !! ## ** ==
        TEXT-ONLY mail to the complete "Reply-To:" address ("My Name" <my@address>) may
        bypass the spam filter. I will answer all pertinent mails from a valid address.

        Comment

        • mr_burns

          #5
          Re: dynamic $_POST - help please

          Hi again,

          Sorry, my mistake. I hadnt properly named the text box to link up with
          the script. Thanks for the help anyway

          Burnsy

          Comment

          Working...