I know this is a stupid question but....

I have a form input page which passes about 10 vars to the next page via <INPUT type=hidden name=string value =$string>. The regular vars are being passed to the action page with no difficulty.
However, when I try to pass a multi-dimensional array to the next page using the same method I get some serisouly strange results. Can you not pass arrays through hidden form elements?

    I've never tried to do such. I use session to save vars like that.

    I believe you can use serialize() and unserialize() to produce the required result that you need though.

    Frag

      Yeah I know...Unfortunatelty I really need to pass the array through the form....

      Just so you know I do not think you can just pass it via a hidden input type....what I had to do is just recreate a similar named array and pass that on to the next page...a real pain.....

        I found this on PHP website as a comment on the serialize() function page.

        If you are passing serialized data between pages in hidden form fields, you need to serialize() the data, then urlencode() it, then put it in the hidden field.

        So you should be able to serialize the array then urlencode it and drop it in the hidden field. You will just have to reverse it on the recieving page.

        I hope this helps you

        Frag

          your answer was right in front of you 🙂

          // example //
          <?
          if($_POST)
          {
          	var_dump($_POST['val1']);
          }
          ?>
          <form action=<?=$PHP_SELF?> method=post>
          <input type="hidden" name="val1[0]" value="0">
          <input type="hidden" name="val1[1]" value="1">
          <input type="hidden" name="val1[2]" value="2">
          
          <input type=submit value=" Calculate ">
          </form>
          

            Yes, I understood that, and that is the work-around I chose.

            What I WANTED to do was take a string created in the above fashion on a previous page, and then forward it to another page just by
            <INPUT type=hidden name=$array value=$array (or array[])>

            Didn't work out that easily......

              what are you using it for? or any example, im not sure what you mean

                Write a Reply...