我正在测试一个 PHP 邮件表单,一个非常简单的表单,在这里可以找到:
<?php
if(isset($_POST['submit']))
{
//The form has been submitted, prep a nice thank you message
$output = '<h3>Thanks for your message</h3>';
//Deal with the email
$to = 'mymail@mail.com';
$subject = 'you have a mail';
$contactname = strip_tags($_POST['contactname']);
$adress = strip_tags($_POST['adress']);
$contactemail = strip_tags($_POST['contactemail']);
$textmessage = strip_tags($_POST['textmessage']);
$boundary =md5(date('r', time()));
$headers = "From: My Site\r\nReply-To: webmaster@mysite.com";
$message = "Name: ".$contactname."\n";
$message .= "Adress: ".$adress."\n";
$message .= "E-mail: ".$contactemail."\n";
$message .= "Message: ".$textmessage."\n";
mail($to, $subject, $message, $headers);
}
?>
问题是我每次在邮件中写单引号或双引号时都会收到不需要的斜杠“\”,因此“I'm”在我的邮箱中显示为“I\'m”。
我知道这与 PHP 区分代码引号和讲座引号的方式有关,但我不知道在我的表单中添加什么以使其正常运行。
任何帮助表示赞赏,