What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Array values of a payment form

    Asked by fredvasse on July 26, 2011 at 08:10 AM

    Hi

    I have created a payment form to order products.

    I want to use the HTPP post function to get the products ordered to show on the Thank You page but I'am not able to deconstruct the multidimensional array it resturns.

     [myproducts1] => Array

            (

                [0] => Array

                [1] => Array

            )

    I have tried to use the below code in my PHP file, but it always returns 'Array' as result:

    $bonproduct = (array_values($_POST['myproducts1'][0]));

    $bonpersons = (array_values($_POST['myproducts1'][1]));

     

    Any ideas?

    Regards

    Fred

    Page URL:
    http://form.jotform.com/fredvasse/12064403437

  • Profile Image
    JotForm Support

    Answered by liyam on July 26, 2011 at 08:25 AM

    Hello Fred,

    If possible, can you provide us a complete post data returned by your form? .

    We'll wait for your response.

     

    Thanks,

    Liyam

  • Profile Image
    JotForm Founder

    Answered by aytekin on July 26, 2011 at 08:28 AM

    Have you tried print_r? That should show you the structure of the second level in your array. Example:

    <? print_r($_POST); ?>

  • Profile Image

    Answered by fredvasse on July 26, 2011 at 08:39 AM

    Tried the print_r option as follows:

    <pre><? print_r($_POST); ?></pre>

    <?

    foreach($_POST as $key => $value){

    if($value !== ""){

    print "$key: $value \n<br />\n";

    }

    }

    ?>

    This wil return the following result:

     

    Array

    (

        [submission_id] => 17749279582941178

        [formID] => 12064403437

        [ip] => 82.94.11.78

        [naamvd] => Fred van der Ende

        [emailvd] => endevander_f@me.com

        [myproducts1] => Array

            (

    [0] => Array

    [1] => Array

            )

        [bericht60] => test message

        [bonnr] => 314

    )

     

  • Profile Image
    JotForm Support

    Answered by liyam on July 26, 2011 at 09:07 AM

    Hello Fred,

    Thank you for posting more details. 

    I have tried the same using var_dump() with selecting all products and the result is similar:

    array(8) {
    ["submission_id"]=>
    string(18) "177494055210565178"
    ["formID"]=>
    string(11) "12063845735"
    ["ip"]=>
    string(12) "210.5.65.178"
    ["naamvd"]=>
    string(4) "liyam"
    ["emailvd"]=>
    string(23) "my@email.com"
    ["myproducts1"]=>
    array(4) {
    [0]=>
    string(5) "Array"
    [1]=>
    string(5) "Array"
    [2]=>
    string(5) "Array"
    [3]=>
    string(5) "Array"
    }
    ["bericht60"]=>
    string(4) "test"
    ["bonnr"]=>
    string(1) "3"
    }

    The product items field is only returning a string value "Array" so we're stuck here and can't dig anything anymore.  I will forward this matter to the development team and let them take a look at this. Unfortunately, I can't give a definite lead time to when they will be able to check this matter.  But when they do, they will respond right away.

    Thank you for your patience.

    -Liyam

  • Profile Image
    JotForm Founder

    Answered by aytekin on July 26, 2011 at 09:12 AM

    var_dump is a good idea. Try that, or this:

    <pre><? print_r( $_POST[myproducts1][0] ); ?></pre>

    <pre><? print_r( $_POST[myproducts1][1] ); ?></pre>

  • Profile Image

    Answered by fredvasse on July 26, 2011 at 09:13 AM

    Hi Liyam

    Thx for the quick response. Happy that I can stop pulling out my hair ;-)

    Fred

  • Profile Image

    Answered by fredvasse on July 26, 2011 at 09:18 AM

    Hi Aytekin

    <pre><? print_r( $_POST[myproducts1][0] ); ?></pre>

    <pre><? print_r( $_POST[myproducts1][1] ); ?></pre>

    Returns

    Array Array
  • Profile Image
    JotForm Founder

    Answered by aytekin on July 26, 2011 at 09:36 AM

    I see. We added this as a bug report.

  • Profile Image

    Answered by fredvasse on July 29, 2011 at 09:25 AM

    Hi Guys

    Any idea when this will be solved? I need the post function for a payment solution in the Netherlands.

    Regards

    Fred

  • Profile Image
    JotForm Support

    Answered by liyam on July 29, 2011 at 10:13 PM

    Hello Fred,

    We apologize for your inconvenience.

    We still have not yet heard updates from the developers.  I have increased the priority of the submitted ticket.  You will hear from them once this has been resolved.

    Thank you for your patience.

    -Liyam

  • Profile Image

    Answered by serkan on August 02, 2011 at 09:42 AM

    Hi Fred,

    In order to fix this issue, I had to convert "Array" parts to JSON strings. All you need to do is to use json_decode($val, true) on these strings and they will convert to proper arrays as you requested.

    Hopefully, we will publish a decent data and notification API soon.

    Thank you for your understanding.

  • Profile Image

    Answered by fredvasse on August 09, 2011 at 05:10 AM

    Hi Serkan

    Thx, I have been trying to decode as follows:

     

    $productdata0 = $_POST['myproducts1']['0'];
    json_decode($productdata0,true);

    This code returns the following output:
    {"name":"Afternoon Tea 15,50 p.p.","options":[{"type":"quantity","name":"Aantal","selected":"2"}],
    "period":"Monthly","pid":"1002","price":"15.50","setupfee":"","trial":"None"}

    However, this dos not seem to be a proper array? How can one get the value of quantity and put it in a function?
    Regards
    Fred
  • Profile Image
    JotForm Founder

    Answered by aytekin on August 09, 2011 at 05:32 AM

    $arr = json_decode($productdata0, true);  // turning json to an assoc array

    print "Quantity: " . $arr{'selected'};

     

  • Profile Image

    Answered by fredvasse on August 09, 2011 at 11:12 AM

    Thx!