HTML form not sending UTF-8 letters from inputs. PHP, MOODLE

159
May 11, 2017, at 6:53 PM

My form and email handler does not send UTF-8 characters from inputs. The email is working correcly, it does support UTF-8 characters, but the ones taken from FORM INPUTS are not coding properly. At this point i have no clue whats wrong.

                   <form id="demo_form" action="/local/landing/demo.php" accept-charset='UTF-8'>
                    <div class="form-text">
                        <div class="form-text-row">
                            <input class="input1 input_all" type="text" required name="name" size="20" placeholder="Imię" />
                            <input class="input2 input_all" type="text" required name="surname" size="20" placeholder="Nazwisko" /> </div>
                        <div class="form-text-row">
                            <input class="input1 input_all" type="email" required name="email" size="20" placeholder="Służbowy adres e-mail" />
                            <input class="input2 input_all" type="text" required name="telephone" size="20" placeholder="Telefon" /> </div>
                        <div class="form-text-row">
                            <input class="input1 input_all" type="text" required name="position" size="20" placeholder="Stanowisko" />
                            <input class="input2 input_all" type="text" required name="company" size="20" placeholder="Nazwa firmy" /> </div>
                        <div class="form-text-row">
                            <div class="form-response"></div>
                            <input type="submit" value="Wyślij" />
                        </div>
                    </div>

Index.php header<meta http-equiv="Content-Type" content="text/html; charset=windows-UTF-8">

PHP email handler

if (!empty($pairs)) {
foreach ($pairs as $pair) {
    list($name, $value) = explode('=', $pair);
    $inputs->$name = $value;
}
$inputs->demo = get_string($inputs->meet, 'land');
$user = $DB->get_record('user', array('id' => 2));
$user->email = 'asd@asd.com';
$supportuser = core_user::get_support_user();
$subject = get_string('subject', 'land');
$html = get_string('message', 'land', $inputs);
$text = strip_tags($html);
if (email_to_user($user, $supportuser, $subject, $text, $html)) {
    $response = 1;
} else {
    $response = get_string('cannot_send', 'land');
}

}

    $string['message'] = ' charset=windows-UTF-8"><p>Wysłano z formularza kontaktowego na stronie logowania.</p>
<p>{$a->name} {$a->surname}<br>
<i>"{$a->position}"</i> z firmy <i>"{$a->company}"</i>
chciał/a by {$a->demo}.</p>
<p>Dane kontaktowe:<br>
email: {$a->email}<br>
telefon: {$a->telephone}</p>';
Answer 1

try to change

<meta http-equiv="Content-Type" content="text/html; charset=windows-UTF-8">

to

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

and in the mail header set to UTF-8

Answer 2

I found out that the problem was in ajax - serialize();

I used decodeURIComponent(data) to decode data from inputs, and its working now.

READ ALSO
How to convert Xls file with formula through PhpExcel

How to convert Xls file with formula through PhpExcel

I have an xls file which i was trying to upload using PhpExcel plugin

194
American spelling using php&#39;s pspell

American spelling using php's pspell

I have a function that auto corrects a stringIt corrects misspelled words as expected

118
Id not getting in input text field using dropdown javascript

Id not getting in input text field using dropdown javascript

I am using javascript for getting dropdown select id id='odrid', here is the script:

239
openssl_encrypt doesn&#39;t work and gives no error?

openssl_encrypt doesn't work and gives no error?

I searched for how to use openssl_encrypt correctly, and found several stackoverflow questions and answersHowever, I'm afraid I just can't get it to work

163