douhao2856 2012-03-25 20:28
浏览 37
已采纳

PHP联系表单换行问题

I have a PHP contact form on my website. I have been using it for about a year now without any problems. Nothing has been updated on my website that has do to with the contact form. However, all of a sudden, when a user enters "line breaks" or "paragraphs" in the message box, when I receive the message, instead of having several paragraphs I have 1 long paragraph with " " in place of line breaks.

Here is the code:

$to = "info@mycompany123.com";
$headers = "From: $email";
$subject = $subject;
$body = "Name: $name

"
. "Email: $email

"
. "Subject: $subject

"
. "Message: $message" ;

mail ($to, $subject, $body, $headers) ;

I really do not know why it started doing this out of the blue but any help is greatly appreciated!

  • 写回答

1条回答 默认 最新

  • donglu9872 2012-03-25 20:30
    关注

    try to convert your message using the nl2br($row['message']); function when you are displaying the messages.

    $row['message'] is just an example, it can be any string.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 安装 opencv4nodejs 报错
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!