简体   繁体   English

PHP联系表格换行问题

[英]PHP contact form linebreak issue

I have a PHP contact form on my website. 我的网站上有一个PHP联系人表格。 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 "\\r\\n" in place of line breaks. 但是,突然之间,当用户在消息框中输入“换行符”或“段落”时,当我收到消息时,我没有使用多个段落,而是使用1个长段落,用“ \\ r \\ n”代替换行符。

Here is the code: 这是代码:

$to = "info@mycompany123.com";
$headers = "From: $email";
$subject = $subject;
$body = "Name: $name\n\n"
. "Email: $email\n\n"
. "Subject: $subject\n\n"
. "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! 我真的不知道为什么它突然开始这样做,但是非常感谢您的帮助!

try to convert your message using the nl2br($row['message']); 尝试使用nl2br($row['message']);转换您的消息nl2br($row['message']); function when you are displaying the messages. 显示消息时的功能。

$row['message'] is just an example, it can be any string. $ row ['message']只是一个例子,可以是任何字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM