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

    Send Post Data Feature: Array problem

    Asked by tinylino2 on June 09, 2011 at 05:41 PM

    On my custom thank you php, when I receive a write in answer it states as (array) rather then the answer that was written in, it works otherwise with any other response xcept the write in.

     

    [ditrict1] => Array ( [0] => Jordan ) is what I receive from form, but in the section using  provides result Array

  • Profile Image
    JotForm Support

    Answered by liyam on June 11, 2011 at 01:46 AM

    Hello tinylino2,

    Thank you for posting your problem.

    Can you share more details about this issue such as the form in issue and the complete tree result of the array?  I'm not sure exactly how to read this as this detail is too short but it seems that I'm looking at a multi-level array.

    May I know as well your code behind your thank-you page and how do you extract your array tree? If you're using print_r, it might be better if you use var_dump as this prints boolean results as well.

    I'll wait for your response.

    Thanks,

    Liyam

  • Profile Image

    Answered by tinylino2 on June 23, 2011 at 04:19 PM

    Array ( [submission_id] => 174669162243212635 [formID] => 11572124139 [ip] => 55.55.555.55 [unitedstates] => Array ( [0] => Jordan ) [district1] => Array ( [0] => Testing more ) [governorand] => John Miller/Parker Smith REP [stateattorney] => Lolita Grooter REP [statechief] => Clay Nutter REP [commissionerof] => Rita West REP [staterepresentative] => Fred Eisenhower DEM [countycommissioner] => Array ( [0] => LALA ) [district2] => Chad Hoffenback REP [shalljustice64] => NO [shalljustice] => NO [circuitjudge] => Gretta Hoffner [soiland] => Daniel Francesco [repealof] => NO [balancingthe] => NO [testuser] => TU26 )

     

    Every time I use php to provide me with answer it works except for write in options.  As you can see, every time I have a write in option I get i.e [unitedstates] => Array ( [0] => Jordan ) the write in was jordan and on the form it states array instead of the answer Jordan.  What would be the code for me to display the write in answer of Jordan rather then array?

    <?php echo $_POST['unitedstates']; ?>  this is what I use to add the text in my thankyou.php, works with all the questions on the form xcept for when a person writes in an anwer I get array...not the write in???

  • Profile Image
    JotForm Support

    Answered by liyam on June 23, 2011 at 10:45 PM

    Hello tinlylino2,

    That is what you call a multidimensional array.  This is what your array would look like:

    Array ( [submission_id] => 174669162243212635
        [formID] => 11572124139
        [ip] => 55.55.555.55
        [unitedstates] =>
            Array ( [0] => Jordan )
        [district1] =>
            Array ( [0] => Testing more )
        [governorand] => John Miller/Parker Smith REP
        [stateattorney] => Lolita Grooter REP
        [statechief] => Clay Nutter REP
        [commissionerof] => Rita West REP
        [staterepresentative] => Fred Eisenhower DEM
        [countycommissioner] =>
            Array ( [0] => LALA )
        [district2] => Chad Hoffenback REP
        [shalljustice64] => NO
        [shalljustice] => NO
        [circuitjudge] => Gretta Hoffner
        [soiland] => Daniel Francesco
        [repealof] => NO
        [balancingthe] => NO
        [testuser] => TU26 ).

     

    So to be able to get the answer jordan, you should use this code:

    $_POST['unitedstates'][0]

    If you want to get the value of district 1, the same should be used:

    $_POST['district1'][0]

    You can learn more about multidimensional arrays here.

    If you have other questions or concerns, please let us know.

    Thanks,

    liyam

  • Profile Image

    Answered by tinylino2 on June 27, 2011 at 10:40 AM

    Array
    (
    [governorand] => Array
    (
    [0]
    )

    So i need to add something like the above, above the header?  How will that provide me with the [0] array? 

  • Profile Image
    JotForm Support

    Answered by liyam on June 27, 2011 at 11:37 AM

    Each set of square brackets used in the variable ([ and ]) represent an array container or key.  So if you are trying to get an array within an array, you will need another set of square brackets and find it's identifying value that will post what's inside it.

    [0] represents a key in the array above. If there are more array values under one key, you will need to use that key to be able to get the values inside it (yes, it's confusing).  So what you are actually doing is using the keys to extract the values inside it.

    I'm not sure about what you posted on your reply since the value inside the key [governorand] is a blank array, but here is a sample on how it goes:

    Try playing around with this sample script:

    <?php

    $_POST = Array ( 'submission_id' => '174669162243212635',
        'formID' => '11572124139',
        'ip' => '55.55.555.55',
        'unitedstates' =>
            Array ( '0' => 'Jordan' ),
        'district1' =>
            Array ( '0' => 'Testing more' ),
        'governorand' => 'John Miller/Parker Smith REP',
        'stateattorney' => 'Lolita Grooter REP',
        'statechief' => 'Clay Nutter REP',
        'commissionerof' => 'Rita West REP',
        'staterepresentative' => 'Fred Eisenhower DEM',
        'countycommissioner' =>
            Array ( '0' => 'LALA' ),
        'district2' => 'Chad Hoffenback REP',
        'shalljustice64' => 'NO',
        'shalljustice' => 'NO',
        'circuitjudge' => 'Gretta Hoffner',
        'soiland' => 'Daniel Francesco',
        'repealof' => 'NO',
        'balancingthe' => 'NO',
        'testuser' => 'TU26' );

    echo $_POST[submission_id];  // will result to '174669162243212635'
    echo $_POST[ip]; // will result to '55.55.555.55'
    echo $_POST[unitedstates]; // will result to Array
    echo $_POST[unitedstates][0]; // will result to 'Jordan'
    echo $_POST[district1]; // will result to Array
    echo $_POST[district1][0]; // will result to 'Testing more'

    ?>

  • Profile Image

    Answered by tinylino2 on June 27, 2011 at 12:02 PM

    www.knowmyvote.org/thankyou/thankyou.php  is the answer sheet that I am trying to work out.

    <tr>
         <td class="style11" style="width: 17px">1</td>
         <td class="style11" style="width: 203px">United States
         Senator</td>
         <td class="style8"><?php echo $_POST['governorand'][0]; ?></td>
        </tr>
        <tr>
         <td class="style11" style="width: 17px; height: 19px;">2</td>
         <td class="style11" style="width: 203px; height: 19px;">Representative in
         Congress</td>
         <td class="style8"><?php echo $_POST['stateattorney'][0]; ?></td>
        </tr>
     

    Form: http://www.knowmyvote.org/assessment/default.html

    I am needing to be able to provide either a name, or a write in answer, and yes, talk about confusing, should be simple, place either a name or a write in answer.  I thought that this <?php echo $_POST['stateattorney'][0]; ?> would do it.  I looked at the help section, but it confuses me even more LOL.  That states either place 'stateattorney' or [write in answer] correct?  If so, am I missing <? ....... ?> above that gives stateattorney a different array?

    The question is choose a state attorney, i have 5 choices and a write in choice, if i get the write in choice to work then the available names dont, if i get available names to work then the write in choices come up as array :-)....

    Thank you sooooo, much for your help,

     

  • Profile Image

    Answered by tinylino2 on June 27, 2011 at 12:10 PM

    adding to above post, adding  Array ( '0' => 'Jordan' ), would give me the anser Jordan correct, how can i tell it that '0' is a write in answer from the user?

  • Profile Image
    JotForm Support

    Answered by liyam on June 27, 2011 at 12:41 PM

    Hmmm... I see now, so the multidimensional array only initiates when you are selecting "Other" on your radio options.

    You can try this one then:

    echo (is_array( $_POST['governorand']) ? $_POST['governorand'][0] : $_POST['governorand']);

    This is what you call a short hand if-else statement that checks if the posted data is an array. if the data is an array then it adds the [0], if not then it posts the exact value.

    Try doing that in every radio buttons set that you have "other" as one of the options.

    -Liyam

  • Profile Image

    Answered by tinylino2 on June 27, 2011 at 01:21 PM

    THAT FIXED IT, thank you very much.

     

    !!!!!

  • Profile Image
    JotForm Support

    Answered by liyam on June 27, 2011 at 01:26 PM

    It's good to know that the solution worked!

    If you have other questions or concerns, please don't hesitate to start a topic.  We'll be here to assist.

    Warm regards,

    -Liyam

  • Profile Image

    Answered by tinylino2 on June 28, 2011 at 08:05 AM

    Hey guys since we have it working now, is there a way to reset the counter to 0 all the 54 submissions were just testing the site

    ... we are going to join one of the pricing plans asap, prob, today.....

     

    Mike

  • Profile Image
    JotForm Founder

    Answered by aytekin on June 30, 2011 at 05:18 AM

    It will reset on the 1st day of July, so I don't think it is necessary to reset the monthly counts.

    If you mean the test submissions on your Submissions page, you can reset them by right clicking on your form on My Forms page and then selecting Clear All Submissions option.