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

    UTF8 Encoding

    Asked by celtsoc on January 12, 2016 at 02:40 PM

    There appears to be a difference in the way text in a text box and a text area controls are utf8 encoded.  I am grabbing the data from my form in a php script as part of a custom thank you page.  The script handles the text box data and the text area data in exactly the same way (Adding it to a mySQL database). The same word appears in the data from a text box and a text area control.  In the text box data, the word is UTF8 encoded but in the text area data, it is not utf8 encoded.

    Is there a setting somewhere in these controls that determine how they are encoded?

    Pete

    custom thank you same and thank
  • Profile Image

    Answered by victor on January 12, 2016 at 04:50 PM

    Thank you for contacting us. You can modify the encoding page using the following suggestion. 

    1. Don't use addslashes()! Use mysql_real_escape_string().  Be careful using strlen(), it may count the bytes and no the characters.

    2. Send a utf-8 header from php before you send any of the page's content: header("Content-type: text/html; charset=utf-8");

    3. As soon as you connect to mysql, do a mysql_query("SET NAMES 'utf8'"); to set the connection's encoding to utf-8, which is often necessary in php/mysql apps.

    4. You want this meta tag in the <head> section to be absolutely safe:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    Please let us know if this helps.

  • Profile Image

    Answered by celtsoc on January 12, 2016 at 06:46 PM
    Doesn't really help. The point I'm making is that text from a text box
    field arrives in my php program correctly utf encoded but text from a text
    area control doesn't. I process the text in exactly the same way and add
    them to mySQL exactly the same. The problem isn't with mySQL, it's with
    how jotform is processing the text before posting it to my php script.
    ...
  • Profile Image
    JotForm Support

    Answered by Kevin_G on January 12, 2016 at 10:49 PM

    Hi,

    You can try using this PHP function : utf8_encode($s),$s is the variable, as I assume you are receiving the data via POST method.

    You will also find more info related to it on this link.

    Hope this helps.

    Regards.

     

  • Profile Image

    Answered by celtsoc on January 13, 2016 at 06:46 PM
    Thanks, I'm familiar with utf8_encode but, once again, that's not the issue.
    I insert a mySQL table row from the data you send me in the php $_POST
    variable. That data includes text from a text box control and text from a
    text area control. They are each inserted into different columns in the
    row which are defined exactly the same in the schema and I don't process
    either one of them further in my script. When I select the data from the
    database, the column containing the text box data is correctly utf8-encoded
    and the column containing the text area data is not. I see exactly the
    same result if I examine the two columns using phpMyAdmin.
    My conclusion is that you send me data from text boxes utf-8 encoded but
    the data you send from a text area control is not utf8-encoded. . What I am
    asking for is confirmation of that before trying to figure out how to deal
    with it.
    Thanks,
    Pete
    ...
  • Profile Image
    JotForm Support

    Answered by Kevin_G on January 13, 2016 at 09:30 PM

    Hi,

    I checked and I can see the data submitted is encoded using UTF-8, it's quite odd, since you say only the Text Area is not being encoded with UTF-8.

    Have you checked if the field in your table is set with UTF-8 ?

    If you are receiving the data without UTF-8 encode, you can use the function provided above, try doing it and let us know the result.

    Thanks.

  • Profile Image

    Answered by mrchairman on October 06, 2016 at 12:00 AM

    Hi I have the similar problem when tried to grab the data insert into mysql UTF8

    After

                function stripslashes_deep($value){

    $value = is_array($value) ?

    array_map('stripslashes_deep', $value) :

    stripslashes($value);

    return $value;

     

    //json to php

     

    $result = stripslashes_deep($_REQUEST['rawRequest']);

     

     

    $obj = json_decode($result, true);

     

    I debug the result and found this

    {"slug":"submit/62783803236459/","input_language":"Thai","q20_input20":{"first":"u0e17u0e14u0e2au0e2du0e1au0e1au0e2du0e35u0e01u0e01","last":"u0e2du0e22u0e32u0e01u0e01u0e25u0e2du0e07u0e07"},"q72_input72":"u0e2du0e49u0e19u0e19u0e19","q69_input69":{"area":" 088","phone":"3557777"},"q68_email":"mm@live.com","q73_input73":"u0e17u0e35u0e48u0e2du0e2du0e2du0e2du0e2du0e2du0e2du0e2du0e2du0e2du0e2du0e2d","q7_input7":"35","q11_input11":"189","q10_input10":"67","q37_input37":"u0e2du0e22u0e32u0e01u0e01u0e25u0e14u0e14u0e14u0e14u0e14u0e14u0e14u0e14u0e14u0e14u0e14u0e14u0e14u0e14u0e14","q67_input67":["2 u0e2au0e31u0e1bu0e14u0e32u0e2bu0e4c"],"q71_input71":"lineeidddddddddddd","event_id":"1475726050218_62783803236459_aQKkcBt"}

     

    and after json_decode

    "q72_input72":"u0e2du0e49u0e19u0e19u0e19"

    The $obj still be the same value

    u0e2du0e49u0e19u0e19u0e19

  • Profile Image
    JotForm Support

    Answered by seth on October 06, 2016 at 01:46 AM

    Your question is addreesed to the following thread.

    https://www.jotform.com/answers/952806

    Please follow the thread to find an answer for your problem, support team would be on this as soon as possible.