我对PHP知之甚少,并试图为我帮助开发的网站制作联系表格。 PHP表单发送电子邮件,但无论出于何种原因,不会使用联系人页面中的输入字段替换变量。该网站是SWFDA。这是我创建的PHP表单:
onSwipeDown()
这是表单的HTML。
<?php
if(!isset($_POST['submit'])) {
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
$email_from = 'myemail@website.com';
$email_to = 'myemail@website.com';
$email_subject = 'Contact Form Submission (Under testing)';
$email_body = 'You have received a form submission from $name .
Email: $visitor_email .
Here is the message: $message'.;
mail($email_to,$email_subject,$email_body);
header('Location: contact-sent.html');
}
?>
收到的电子邮件如下:
您收到了来自$ name的表单提交。
电子邮件:$ visitor_email。
这是消息:$ message。
答案 0 :(得分:0)
尝试这样,
$email_body = 'You have received a form submission from '.$name.'
Email: '.$visitor_email.'
Here is the message: '.$message;
或使用双引号&#34; &#34;
$email_body = "You have received a form submission from $name
Email: $visitor_email
Here is the message: $message";
答案 1 :(得分:0)
只需在$email_body
中将单引号(')更改为双引号(“),然后您的电子邮件应如下所示:
<?php
if(!isset($_POST['submit'])) {
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
$email_from = 'myemail@website.com';
$email_to = 'myemail@website.com';
$email_subject = 'Contact Form Submission (Under testing)';
$email_body = "You have received a form submission from $name .
Email: $visitor_email .
Here is the message: $message".;
mail($email_to,$email_subject,$email_body);
header("Location: contact-sent.html");
}
?>