duanchi0897 2019-07-26 13:19
浏览 80

html / php联系表单中变异元音(变音符号)的问题

German mutated vowels (ö,ä,ü, etc) are not displayed correctly in the emails, sent over a html/php contact-form even the the UTF-8 declaration is set.

PHP file:

    <meta http-equiv="Content-Type" content="text/html"; charset="utf-8" />
<?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $from = 'From: Website'; 
    $to = 'xxx@gmx.de'; 
    $subject = 'Hi there';
    $human = $_POST['human'];

    $body = "From: $name
 E-Mail: $email
 Message:
 $message";
    if ($_POST['submit']) {
    if ($name != '' && $email != '')

In the html file the utf declaration is set as well:

<!DOCTYPE html>
<meta charset="utf-8">

The special characters looks like this "ü"

  • 写回答

1条回答

  • duandu5846 2019-07-26 15:19
    关注

    For php you need to use the header function to make sure that the HTTP header is set to UTF-8.

    Try this link.

    In a nutshell:

    header('Content-Type: text/html; charset=utf-8');
    

    Call this before any data is sent (right after your require and import statements).

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型