How to include external database field data in the autoresponder email?

  • amirw1962
    Asked on April 2, 2018 at 4:49 AM

    Hi,

    I have an insurance PHP/MYSQL application that lets the user with an open contractors insurance policy, provide details of various projects to be insured under the policy.

    In the Jotform he provides all the information, but there is some information retrieved from USERS table based on credentials he types when logging into the system.

    For example, I don't need him to type his full name, his policy number etc. every time he fills the form, because I have this information in USERS table and I can show it on top of the page where the form is found.

    I insert all data (filled by the user + found in USERS table) to the relevant mysql database/table, but my question is if I can add these fields to the email sent with form data.

    The email seems to include only form data, but can I add other data found on same page (but not in the form)?

    Alternatively, I can create a duplicate form for every new user and include the additional data in the form title for that user and then add the form script dynamically to the application page based on user credentials (in USERS table I'll include a "script" field, relevant to the specific user's form).

    Is there a better way to add to the email, data not filled by the user?

    Thanks!

  • Kiran Support Team Lead
    Replied on April 2, 2018 at 6:02 AM

    I understand that you have some data in the MySQL database and you want to add this field data to the JotForm autoresponder. Is that correct? You may consider adding the related MySQL fields to JotForm and populate the data from the database using URL parameters. 

    https://www.jotform.com/help/71-Prepopulating-Fields-to-Your-JotForm-via-URL-Parameters

    You may hide these fields on the form so that the user will not be displayed with these fields.

    Since, the fields are now available on the form, they can be automatically included in the autoresponder. If the email is not updated automatically, please try deleting the email from the form settings and add a new email autoresponder.

    Hope this information helps! Please give it a try and let us know if you need any further assistance. We will be happy to help. 


  • amirw1962
    Replied on April 2, 2018 at 6:15 AM

    Yes, this is correct!
    It sounds like a great solution, I'll try it.

    Thanks!

  • amirw1962
    Replied on April 2, 2018 at 7:11 AM

    Hi again,

    I understand now the concept of URL parameters but I am not sure how to integrate it.

    I use to embed the form code on a page displayed to the user and I don't use the form URL whereby I can add the parameters.

    Is it recommended to embed the form using the IFRAME method now, so I can add the parameters to the IFRAME URL? Is this the way to do it?

    In addition, I use PHP to retrieve data from MYSQL table, something like:
    $company=mysql_result($result,0,"company");

    If I embed the form using IFRAME, and the short version of the IFRAME is:
    <iframe id="JotFormIFrame-73327031919456" src="https://form.jotform.me/73327031919456??">, and if the company variable used by Jotform is compName[ins], could you demonstrate how I add the $company variable? 
    I can start PHP after the ?? in URL, add the variable and get back to HTML, but I'm not sure if this will be acceptable. The URL parameter can accept variables and not just values?

    Is this the way to deal with it or I'm going the wrong way?

    Thanks!



  • Adrian
    Replied on April 2, 2018 at 8:43 AM

    Is it recommended to embed the form using the IFRAME method now, so I can add the parameters to the IFRAME URL? Is this the way to do it?

    Yes, that is the correct way to do it. You should embed the form using the Iframe code.

    I can start PHP after the ?? in URL, add the variable and get back to HTML, but I'm not sure if this will be acceptable. The URL parameter can accept variables and not just values?

    Yes, you can use PHP variables in the src attribute of the Iframe. The Iframe could look something like this:

    <iframe id="JotFormIFrame-73327031919456" src="https://form.jotform.me/73327031919456?email=<?php echo $userEmail; ?>&fullName=<?php echo $userName; ?>&phoneNumber[area]=1&phoneNumber[phone]=1234567890">

    Let us know if you need further help.

  • amirw1962
    Replied on April 2, 2018 at 9:14 AM

    Thanks! Everything is clear now.