Note that there are some explanatory texts on larger screens.

plurals
  1. POUTF-8 characters in an email form
    primarykey
    data
    text
    <p>The below code should result in a UTF-8 encoded email via a contact form that sends data to the relevant database table. However, it's still not showing UTF-8 characters correctly. Can you see if I've mis-typed/not added/messed up with the code below? Many thanks!</p> <pre><code>&lt;?php $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key =&gt; $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j &gt;= 20) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 20 - $j; for ($i = 1; $i &lt;= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '&lt;META HTTP-EQUIV=Refresh charset=utf-8 CONTENT="0; URL='.$url.'"&gt;'; ?&gt; </code></pre> <p><strong>EDIT:</strong></p> <p>Thanks for the rapid response Chris - on second thoughts, however, our email form relies on a 'func.php' file with various settings for the site included. Currently the 'sendemail' code is as follows:</p> <pre><code>$headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; $headers .= "From: ".$hostmail." \r\n"; $headers .= "Reply-To : ".$hostmail." \r\n"; return mail($to, $subj, $body, $headers); </code></pre> <p>I've tried altering is as follows, without success... any ideas?</p> <pre><code>$headers .= "From: ".$hostmail." \r\n"; $headers .= "Reply-To : ".$hostmail." \r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=utf-8\r\n"; $headers .="Content-Transfer-Encoding: 8bit"; $body=htmlspecialchars_decode($body,ENT_QUOTES); return mail($to, "=?utf-8?B?".base64_encode($subj)."?=",$body, $headers); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload