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

    Extract correct field names from webhook $_POST?

    Asked by DrFischer on December 30, 2013 at 05:32 PM

    Hi,

    I created a webhook from one of my forms that triggers the page "webhook.php" on my server. This page runs a script, that collects all $_POST data, serializes it und writes the raw data into a MYSQL database (and also sends it via email to me). Everything seems to be working well, but I have problems getting the correct field names out of the raw data. The $_POST data shows field names klike "q730_osteoporosisOr", while in my jotform, the field actually is called "Osteoporosis or osteopenia". How can I get the data extracted correctly?

    Thank you

    R.

    field names My Forms JotForm email style size
  • Profile Image
    JotForm Support Manager

    Answered by Jeanette on December 30, 2013 at 10:51 PM

    Actually, what you get is the ID of each field variable, which is basically identified by an HTML element

    You might need to get these ID's and put them into variables that you can further arrange into your own MYSQL database fields accordingly

    Please check this guide for further help

    http://www.jotform.com/help/126-Form-to-MySQL

  • Profile Image

    Answered by DrFischer on December 30, 2013 at 11:58 PM

    Thank you. Yes, I know, these are the IDs, but what I want is the names of the fields. My forms may have more than 200 questions, and I am planning to enter bigger quesitonnaires with 500 questions, and I would like to send the field names with ther answers, not just the IDs, similar to the emails that I get when a form is submitted. These emails actually list all the field names long with their contents, not just the field IDs. Is there away to get that? I just do not want to create a mysql table with 500 fields, and whenever I decide to change a couple things in my form, I will have to revamp my myhsql table.

    I already tried to connect to my MYSQL database via Zapier, but the interface is just not made for forms with 40 or more fields. WHen creating a new zap, I have to select every single field manually, and the more fields are selected, the longer it takes to register them, and at some point it just doesnt work any more at all.

    Your input is much appreciated, thanks!

  • Profile Image
    JotForm Support

    Answered by EltonCris on December 31, 2013 at 01:02 AM

    @DrFischer

    You can actually use post directly with the provided field names e.g. $_POST['q730_osteoporosisOr'], this is used for Webhook but if that's an HTTP Post data, you can use $_POST['osteoporosisOr'] without the prefix q730_

    To find out field names to be used on post data, please enable HTTP Post data on your form.

    Then enter this URL as your "Thank you" Custom URL: https://www.jotform.com/show-post-data

    Make a test submission with your form after that, it should dump the data on the thank you page along with the formatted $_POST codes.

    Let us know if I've misunderstood your question. Thanks!

  • Profile Image

    Answered by DrFischer on December 31, 2013 at 01:21 AM

    EltonCris,

    I am not sure what you are suggesting... the $_POST codes still show the field IDs, not the field NAMES, but maybe I misunderstood. Anyway, the field $_POST['osteoporosisOr'] actually is called "osteoporosis or osteopenia" in my jotform, and my quesiton sitll remains the same: how can I get my jotform to post the field name (e.g. "osteoporosis or osteopenia") along with the answer instead of the field id (e.g. "osteoporosisOr")?

  • Profile Image

    Answered by DrFischer on December 31, 2013 at 01:34 AM

    by "field name" I mean the actual question, e.g. if a Yes/No question in my jotform reads as "Osteoporosis or Osteopenia", and the user clicks "No" on this particular question, the jotform will post "q720_osteoporosisOr => No", while I want it to post "Osteoporosis or osteopenia => No".

  • Profile Image

    Answered by DrFischer on December 31, 2013 at 01:44 AM

    For example, here is a "print_r" from the webhoop.php I created:

     

    q3_name3 --> Array
    q6_dateOf --> Array
    q231_sex --> Male
    q118_heightinches --> 89
    q119_weightpounds --> 210
    q5_contactNumber --> Array
    q232_maritalStatus232 --> Single
    q4_address4 --> Array
    q225_email --> www@aznd.com
    q13_emergencyContact13 --> Array
    q73_relationship --> Brother
    q74_contactNumber74 --> Array
    q629_whatIs629 --> Low Back Pain
    q724_pleaseDescribe --> 
    q633_location --> right side
    q726_doYou --> Array
    q610_doYou610 --> No
    q686_typeOf686 --> 
    q623_doYou623 --> No
    q641_pleaseList641 --> 
    q22_pleaseList22 --> none
    q628_pleaseList628 --> none
    q580_pleaseList580 --> none
    q582_pleaseList582 --> none
    q729_doYou729 --> none
    q583_pleaseList583 --> none
    q585_pleaseList --> none
    q736_areYou --> No
    q596_anxiety --> No
    q644_depression644 --> No
    q646_dementia --> No
    q645_epilepsy --> No
    q647_migraine --> No
    q672_arthritis672 --> No
    q671_backProblems671 --> No
    q670_asthma670 --> No
    q669_copd --> No
    q668_pneumonia --> No
    q667_tb --> No
    q666_chronicHeart --> No
    q665_coronaryArtery --> No
    q664_highCholesterol --> No
    q663_highBlood663 --> No
    q662_heartAttack --> No
    q661_stroke --> No
    q660_anemia660 --> No
    q659_diabetes --> No
    q658_gout658 --> No
    q657_renalStone --> No
    q656_thyroidDisease --> No
    q655_gerd --> No
    q654_ulcer --> No
    q653_bph --> No
    q652_cancer --> No
    q651_dermatitis --> No
    q650_hepatitis650 --> No
    q649_hiv --> No
    q648_glaucoma648 --> No
    q730_osteoporosisOr --> No
    q731_dizziness731 --> No
    q732_vertigo --> No
    q733_neckInjury --> No
    q734_arteriosclerosis734 --> No
    q735_impairedBlood735 --> No
    q689_otherplease --> 
    q690_standard --> Emergency Contact
    q723_end --> 
    q278_system278 --> End

     

    I can not use this for my purposes, I need the actual questions, not the field IDs.

  • Profile Image
    JotForm Support

    Answered by ardy0689 on December 31, 2013 at 09:34 AM

    Thanks for providing us this detailed information. If you are after the $_POST data from the form, you should not trigger it via Webhook feature. You should trigger your script via Thank You URL redirection and keep the Send HTTP POST data to YES just like what my colleague Elton has illustrated to you.

    Enabling HTTP POST data

     

    Trigger your script after form submit via Custom URL Redirection.

    Paste the location of your webhook.php as the Custom URL. You should not use Webhook when getting HTTP POST data

     

    Please take a look at this sample demo form and this webhook.php I made. If you take a close look on the script, this is the only extent on what you can fetch from HTTP POST DATA regardless of how many fields you have, you will always have the option to retrieve Submission ID, Form ID, IP address.

    I am afraid you can only fetch values and no field labels or texts. Even if you use the actual Webhook feature to trigger the script it will also give you values only. No labels.

    If you need further assistance, please do not hesitate to ask. Thank you

  • Profile Image

    Answered by DrFischer on December 31, 2013 at 09:39 AM

    Thank you. The form email that is sent to me does have the labels instead of the IDs. Is there any eay to get the field labels from that?

  • Profile Image

    Answered by DrFischer on December 31, 2013 at 09:42 AM

    Also, I am not sure I understand why not yo use webhook. What are the webhooks for? Thanks for teaching a rookie :)

  • Profile Image
    JotForm Support

    Answered by ardy0689 on December 31, 2013 at 01:35 PM

    Thanks for replying back. Let me explain to you that further why you should enable HTTP POST and redirect to a custom URL. Since you mentioned $POST or POST Data on your thread title, Webhook feature does not return an output of HTTP POST but instead it returns an output of Raw Request headers in JSON format not POST data.

    See illustration here POST Data vs. RawRequest output from Webhook.

    It is a matter or preference on what kind of output would the form will give you. Either way will work but different coding approach. Fetching the data via HTTP POST requires you to redirect after submission. This will not allow you to use the Thank you message feature. While fetching data using Webhook will execute silently upon submission. Plus, you will have the ability to use Thank you message feature.

    Clearly, using webhook has its advantages and more powerful to use than redirecting to a URL to execute your script.

    The form email that is sent to me does have the labels instead of the IDs. Is there any eay to get the field labels from that?

    The email is programmed to fetch the labels it is a different sub system of JotForm. While the form submission itself is another system which have no ability to fetch field labels as HTML forms are designed to pass values only without their fields. This is the same limitation when you use forms made by JotForm.

    A workaround for that is to use a hidden box widget

     

    This is of course hidden to your users, you can assign a default value like "Full Name" or any label of the field you want. This will be seen and can be fetch via HTTP POST or via Webhook.

    If you need further assistance, please do not hesitate to ask. Thank you

  • Profile Image

    Answered by DrFischer on December 31, 2013 at 01:49 PM

    thank you. I dont really understand how the hidden fild should work. Are you saying that for every field in my quesitonnaire, I should put a hidden field, that contains the field name? how will i know what field this name field is belonigng too? It looks I will also have to put the corresponding field id in that hidden field. with 200+ fields in a questionnaire, which is kind of a hassle...

    I could also put a hidden field into the form, that contains a colleciton of all field ids and their corresponding field labels. which is also kind of a hassle...

    but maybe I misunderstood?

  • Profile Image

    Answered by DrFischer on December 31, 2013 at 04:22 PM

    Maybe there is another, much more elegant solution within jotform. The reason why I want the field labels and why I am doing a webhook is that I have to process the form data to create result data that I can copy/paste into my EHR system. Let me give you an example:

     

    My form would probably look like this:

     

    Respiratory
    ------------

    Stuffy Nose  - YES (PAST) NO
    Sinus Trouble  - YES (PAST) NO
    Frequent Sore Throat - YES PAST (NO)
    Shortness of Breath  -  (YES) PAST NO
    Cough  - YES PAST (NO)
    Chills -  YES (PAST) NO
    Difficulty Breathing  -  (YES) PAST NO
    Wheezing  - YES PAST (NO)
    Coughing Blood  - (YES) PAST NO

     

    Cardiovascular
    -------------
    Heart Murmur -  YES PAST (NO)
    Chest Pain  - YES (PAST) NO
    Palpitations  -  YES (PAST) NO
    Dizziness  -  YES PAST (NO)
    Fainting Spells  -   (YES) PAST NO
    Shortness of Breath  -  (YES) PAST NO
    Difficulty Lying Flat  - YES PAST (NO)
    Swelling Ankles   - YES (PAST) NO

    etc.

     

    The user's choices are marked with ()

     

    Now, I want the form to create the foillowing output:

     

    Respiratory
    -----------
    Patient reports Shortness of Breath, Difficulty Breathing, Coughing Blood.

    Patent reports past history of Stuffy Nose, Sinus Trouble, Chills.

    Patient denies history of Frequent Sore Throat, Cough, Wheezing.

     

    Cardiovascular
    --------------

    Patient reports Shortness of Breath, Fainting Spells.

    Patient reports past history of Swelling Ankles, Chest Pain, Palpitations.

    Patient denies history of Difficulty Lying Flat, Heart Murmur, Dizziness.

    etc.

     

    Is that possible within jotform, maybe with a report? That would be great, because then I would not need the webhook at all, I could just copy/paste it directly from the form result.

  • Profile Image

    Answered by DrFischer on January 02, 2014 at 04:51 PM

    Hey, anybody out there who has an asnwer to this? thanks

  • Profile Image
    JotForm Support

    Answered by ardy0689 on January 02, 2014 at 06:39 PM

    Hello. I apologize for the delayed response. Let me address your previous posts individually.

    Are you saying that for every field in my quesitonnaire, I should put a hidden field, that contains the field name? how will i know what field this name field is belonigng too? It looks I will also have to put the corresponding field id in that hidden field. with 200+ fields in a questionnaire, which is kind of a hassle...

    I could also put a hidden field into the form, that contains a colleciton of all field ids and their corresponding field labels. which is also kind of a hassle...

    You are correct on your part that it is hassle to use the hidden field method especially you mentioned you have more than a hundred fields. Honestly, that is also a good move that you mentioned adding the field IDs in the hidden field and just use 2 hidden boxes for collections of IDs and Labels. Nice thinking! :)

    Because JotForm is also an HTML form with advanced features, it is still just an HTML form and natively it uses <input> fields to pass data to and from. If we do not use hidden fields we have no container to carry the field labels to be outputted via POST or via Webhook.

    Maybe there is another, much more elegant solution within jotform."

    Regarding this post and the sample draft of what you are trying to achieve, yes this is possible by using the form source code and host it on your server. Then you need to accompany it with custom scripts using Javascript to automatically collect all Labels and IDs that are present on the form and put it on 2 hidden boxes that you will put. So it lessens the hassle of putting many hidden fields and let the script do the hard work for you. Then let the Webhook feature collect all passed data from the input fields and reference from the hidden box for their labels.

    Please let us know if you want to take this approach and provide us with your basic form created from the form builder so that I can provide you with a custom script that you can use. Thank you

  • Profile Image

    Answered by DrFischer on January 02, 2014 at 06:54 PM

    Hi, thankyou for your reply. Your form soruce code solution sounds like a really good workaround, but the reason why I want to host it on your server is that you claim to be HIPAA compliant, and my forms collect personal identification date form my partients. I know this is tricky, but do you have any other ideas? thanks again

  • Profile Image
    JotForm Support Manager

    Answered by Jeanette on January 02, 2014 at 11:24 PM

    If you want to host the data in our servers, you do not need to use the workaround and send form data through PHP/MySQL,  you can still customize the source code of the form and still be able to send the data to our servers.

    For a better explanation on how to be HIPAA compliant using Jotform, let me tell you that  data stored on our servers is not encrypted, but access to our servers is safeguarded.

    Data transmission from the person who submits their health information to our servers can be done in an encrypted manner, by using the forms securely.

    JotForm certainly complies with the technical safeguard section of the HIPAA security rule:

    Information systems housing PHI must be protected from intrusion. When information flows over open networks, some form of encryption must be utilized. If closed systems/networks are utilized, existing access controls are considered sufficient and encryption is optional.

    But to achieve this, you must follow these advises:

    1. Always use SSL (https) version of JotForm site on your browser. Use "https://www.jotform.com" to login to your account, create your forms, look at your submissions and link to your forms.

    2. Edit emails on all forms to make sure no specific information is used on them. We send emails in plain text. So, they are not secure. Only use emails to get alerts to know there is a new submission. Once you receive an email alert, log into the secure JotForm site and then look at the user 

    3. If you use the Reports feature only do it with password protection. That will both ask for a password, and it will transfer all data over SSL.

    4. Same for uploads. They are not password protected.

    5. Logout immediate after you are done with the site.

    6. Regularly download submissions and then delete them.